@chaibuilder/sdk 2.2.29 → 2.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +4 -4
- package/dist/core.d.ts +7 -0
- package/dist/core.js +958 -942
- package/dist/render.cjs +2 -2
- package/dist/render.js +76 -68
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +1 -1
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -73,8 +73,6 @@ const activePanelAtom = atom("outline");
|
|
|
73
73
|
activePanelAtom.debugLabel = "activePanelAtom";
|
|
74
74
|
const showPredefinedBlockCategoryAtom = atom("");
|
|
75
75
|
showPredefinedBlockCategoryAtom.debugLabel = "showPredefinedBlockCategoryAtom";
|
|
76
|
-
const inlineEditingActiveAtom = atom("");
|
|
77
|
-
inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
|
|
78
76
|
const draggingFlagAtom = atom(!1);
|
|
79
77
|
draggingFlagAtom.debugLabel = "draggingFlagAtom";
|
|
80
78
|
const treeRefAtom = atom(null);
|
|
@@ -299,12 +297,12 @@ class PubSub {
|
|
|
299
297
|
}
|
|
300
298
|
}
|
|
301
299
|
const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
302
|
-
const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (
|
|
303
|
-
if (
|
|
300
|
+
const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (h) => c ? get(h, "_parent") === c : !get(h, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (h) => {
|
|
301
|
+
if (h === "CHILD")
|
|
304
302
|
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
305
303
|
else {
|
|
306
|
-
const
|
|
307
|
-
|
|
304
|
+
const m = { _id: c || "", position: d == null ? void 0 : d.length };
|
|
305
|
+
h === "BEFORE" ? m.position = Math.max(u, 0) : h === "AFTER" && (m.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
|
|
308
306
|
}
|
|
309
307
|
};
|
|
310
308
|
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
@@ -339,20 +337,20 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
339
337
|
let i = [...o];
|
|
340
338
|
if (r) {
|
|
341
339
|
const u = o.find((g) => g._id === r);
|
|
342
|
-
if (u && u.content !== void 0 && u.content !== "" && !o.some((
|
|
343
|
-
const
|
|
340
|
+
if (u && u.content !== void 0 && u.content !== "" && !o.some((h) => h._parent === r)) {
|
|
341
|
+
const m = {
|
|
344
342
|
_id: generateUUID(),
|
|
345
343
|
_parent: r,
|
|
346
344
|
_type: "Text",
|
|
347
345
|
content: u.content
|
|
348
346
|
};
|
|
349
347
|
Object.keys(u).forEach((f) => {
|
|
350
|
-
f.startsWith("content-") && (
|
|
351
|
-
}), l.unshift(
|
|
348
|
+
f.startsWith("content-") && (m[f] = u[f]);
|
|
349
|
+
}), l.unshift(m), i = i.map((f) => {
|
|
352
350
|
if (f._id === r) {
|
|
353
351
|
const x = { ...f, content: "" };
|
|
354
|
-
return Object.keys(x).forEach((
|
|
355
|
-
|
|
352
|
+
return Object.keys(x).forEach((k) => {
|
|
353
|
+
k.startsWith("content-") && (x[k] = "");
|
|
356
354
|
}), x;
|
|
357
355
|
}
|
|
358
356
|
return f;
|
|
@@ -388,13 +386,13 @@ function moveNode(o, n, r, a) {
|
|
|
388
386
|
const l = findNodeById(o, n), i = findNodeById(o, r);
|
|
389
387
|
if (!l || !i) return !1;
|
|
390
388
|
i.children || (i.model.children = []);
|
|
391
|
-
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((
|
|
389
|
+
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((h) => h.model._id === n);
|
|
392
390
|
l.drop(), c = Math.max(c, 0);
|
|
393
391
|
const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
|
|
394
392
|
try {
|
|
395
393
|
i.addChildAtIndex(l, p);
|
|
396
|
-
} catch (
|
|
397
|
-
return console.error("Error adding child to parent:",
|
|
394
|
+
} catch (h) {
|
|
395
|
+
return console.error("Error adding child to parent:", h), !1;
|
|
398
396
|
}
|
|
399
397
|
return !0;
|
|
400
398
|
}
|
|
@@ -435,8 +433,8 @@ function handleNewParentTextBlock(o, n, r) {
|
|
|
435
433
|
const d = o.map((u) => {
|
|
436
434
|
if (u._id === r) {
|
|
437
435
|
const g = { ...u, content: "" };
|
|
438
|
-
return Object.keys(g).forEach((
|
|
439
|
-
|
|
436
|
+
return Object.keys(g).forEach((h) => {
|
|
437
|
+
h.startsWith("content-") && (g[h] = "");
|
|
440
438
|
}), g;
|
|
441
439
|
}
|
|
442
440
|
return u;
|
|
@@ -453,7 +451,7 @@ function moveBlocksWithChildren(o, n, r, a) {
|
|
|
453
451
|
const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
|
|
454
452
|
if (moveNode(p, n, c, a)) {
|
|
455
453
|
let u = flattenTree(p);
|
|
456
|
-
const g = u.find((
|
|
454
|
+
const g = u.find((h) => h._id === n);
|
|
457
455
|
return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
|
|
458
456
|
}
|
|
459
457
|
return i;
|
|
@@ -477,22 +475,22 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
477
475
|
}, removeNestedBlocks = (o, n) => {
|
|
478
476
|
let r = [...o], a = [];
|
|
479
477
|
n.forEach((d) => {
|
|
480
|
-
const p = r.find((
|
|
478
|
+
const p = r.find((h) => h._id === d);
|
|
481
479
|
if (!p || !p._parent) return;
|
|
482
|
-
const u = p._parent, g = r.filter((
|
|
480
|
+
const u = p._parent, g = r.filter((h) => h._parent === u);
|
|
483
481
|
if (g.length === 2) {
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
486
|
-
const
|
|
487
|
-
|
|
482
|
+
const h = g.find((m) => m._id !== d);
|
|
483
|
+
if (h && h._type === "Text") {
|
|
484
|
+
const m = r.find((f) => f._id === u);
|
|
485
|
+
m && "content" in m && (r = r.map((f) => {
|
|
488
486
|
if (f._id === u) {
|
|
489
|
-
const x = { ...f, content:
|
|
490
|
-
return Object.keys(
|
|
491
|
-
|
|
487
|
+
const x = { ...f, content: h.content };
|
|
488
|
+
return Object.keys(h).forEach((k) => {
|
|
489
|
+
k.startsWith("content-") && (x[k] = h[k]);
|
|
492
490
|
}), x;
|
|
493
491
|
}
|
|
494
492
|
return f;
|
|
495
|
-
}), a.push(
|
|
493
|
+
}), a.push(h._id));
|
|
496
494
|
}
|
|
497
495
|
}
|
|
498
496
|
});
|
|
@@ -574,7 +572,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
574
572
|
status: "idle",
|
|
575
573
|
props: {},
|
|
576
574
|
error: void 0
|
|
577
|
-
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`),
|
|
575
|
+
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), h = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
|
|
578
576
|
return useEffect(() => {
|
|
579
577
|
if (n === "mock") {
|
|
580
578
|
if (isFunction(a)) {
|
|
@@ -586,7 +584,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
586
584
|
}
|
|
587
585
|
return;
|
|
588
586
|
}
|
|
589
|
-
n === "live" && (!g && !
|
|
587
|
+
n === "live" && (!g && !h || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
|
|
590
588
|
g ? (p((x) => ({
|
|
591
589
|
...x,
|
|
592
590
|
[o._id]: {
|
|
@@ -601,7 +599,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
601
599
|
[o._id]: { status: "error", error: f, props: [] }
|
|
602
600
|
})), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
|
|
603
601
|
})));
|
|
604
|
-
}, [o == null ? void 0 : o._id, u, g,
|
|
602
|
+
}, [o == null ? void 0 : o._id, u, g, h, a, n]), {
|
|
605
603
|
$loading: get(l, "status") === "loading",
|
|
606
604
|
...o ? get(l, "props", {}) : {}
|
|
607
605
|
};
|
|
@@ -801,50 +799,50 @@ const undoRedoStateAtom = atom({
|
|
|
801
799
|
updateBlocksProps: c
|
|
802
800
|
} = useBlocksStoreManager();
|
|
803
801
|
return {
|
|
804
|
-
moveBlocks: (x,
|
|
802
|
+
moveBlocks: (x, k, b) => {
|
|
805
803
|
const v = map(x, (w) => {
|
|
806
|
-
const
|
|
807
|
-
return { _id: w, oldParent:
|
|
804
|
+
const E = n.find((N) => N._id === w)._parent || null, A = n.filter((N) => E ? N._parent === E : !N._parent).map((N) => N._id).indexOf(w);
|
|
805
|
+
return { _id: w, oldParent: E, oldPosition: A };
|
|
808
806
|
}), B = v.find(({ _id: w }) => w === x[0]);
|
|
809
|
-
B && B.oldParent ===
|
|
810
|
-
undo: () => each(v, ({ _id: w, oldParent:
|
|
811
|
-
i([w],
|
|
807
|
+
B && B.oldParent === k && B.oldPosition === b || (i(x, k, b), o({
|
|
808
|
+
undo: () => each(v, ({ _id: w, oldParent: _, oldPosition: E }) => {
|
|
809
|
+
i([w], _, E);
|
|
812
810
|
}),
|
|
813
|
-
redo: () => i(x,
|
|
811
|
+
redo: () => i(x, k, b)
|
|
814
812
|
}));
|
|
815
813
|
},
|
|
816
|
-
addBlocks: (x,
|
|
817
|
-
a(x,
|
|
814
|
+
addBlocks: (x, k, b) => {
|
|
815
|
+
a(x, k, b), o({
|
|
818
816
|
undo: () => l(map(x, "_id")),
|
|
819
|
-
redo: () => a(x,
|
|
817
|
+
redo: () => a(x, k, b)
|
|
820
818
|
});
|
|
821
819
|
},
|
|
822
820
|
removeBlocks: (x) => {
|
|
823
821
|
var B;
|
|
824
|
-
const
|
|
822
|
+
const k = (B = first(x)) == null ? void 0 : B._parent, v = n.filter((w) => k ? w._parent === k : !w._parent).indexOf(first(x));
|
|
825
823
|
l(map(x, "_id")), o({
|
|
826
|
-
undo: () => a(x,
|
|
824
|
+
undo: () => a(x, k, v),
|
|
827
825
|
redo: () => l(map(x, "_id"))
|
|
828
826
|
});
|
|
829
827
|
},
|
|
830
|
-
updateBlocks: (x,
|
|
828
|
+
updateBlocks: (x, k, b) => {
|
|
831
829
|
let v = [];
|
|
832
830
|
if (b)
|
|
833
831
|
v = map(x, (B) => ({ _id: B, ...b }));
|
|
834
832
|
else {
|
|
835
|
-
const B = keys(
|
|
833
|
+
const B = keys(k);
|
|
836
834
|
v = map(x, (w) => {
|
|
837
|
-
const
|
|
838
|
-
return each(B, (
|
|
835
|
+
const _ = n.find((C) => C._id === w), E = { _id: w };
|
|
836
|
+
return each(B, (C) => E[C] = _[C]), E;
|
|
839
837
|
});
|
|
840
838
|
}
|
|
841
|
-
c(map(x, (B) => ({ _id: B, ...
|
|
839
|
+
c(map(x, (B) => ({ _id: B, ...k }))), o({
|
|
842
840
|
undo: () => c(v),
|
|
843
|
-
redo: () => c(map(x, (B) => ({ _id: B, ...
|
|
841
|
+
redo: () => c(map(x, (B) => ({ _id: B, ...k })))
|
|
844
842
|
});
|
|
845
843
|
},
|
|
846
|
-
updateBlocksRuntime: (x,
|
|
847
|
-
c(map(x, (b) => ({ _id: b, ...
|
|
844
|
+
updateBlocksRuntime: (x, k) => {
|
|
845
|
+
c(map(x, (b) => ({ _id: b, ...k })));
|
|
848
846
|
},
|
|
849
847
|
setNewBlocks: (x) => {
|
|
850
848
|
r(x), o({
|
|
@@ -853,12 +851,12 @@ const undoRedoStateAtom = atom({
|
|
|
853
851
|
});
|
|
854
852
|
},
|
|
855
853
|
updateMultipleBlocksProps: (x) => {
|
|
856
|
-
let
|
|
857
|
-
|
|
858
|
-
const v = keys(b), B = n.find((
|
|
859
|
-
return each(v, (
|
|
854
|
+
let k = [];
|
|
855
|
+
k = map(x, (b) => {
|
|
856
|
+
const v = keys(b), B = n.find((_) => _._id === b._id), w = {};
|
|
857
|
+
return each(v, (_) => w[_] = B[_]), w;
|
|
860
858
|
}), c(x), o({
|
|
861
|
-
undo: () => c(
|
|
859
|
+
undo: () => c(k),
|
|
862
860
|
redo: () => c(x)
|
|
863
861
|
});
|
|
864
862
|
}
|
|
@@ -866,25 +864,25 @@ const undoRedoStateAtom = atom({
|
|
|
866
864
|
}, useAddBlock = () => {
|
|
867
865
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
868
866
|
(i, c, d) => {
|
|
869
|
-
var
|
|
867
|
+
var m;
|
|
870
868
|
for (let f = 0; f < i.length; f++) {
|
|
871
869
|
const { _id: x } = i[f];
|
|
872
870
|
i[f]._id = generateUUID();
|
|
873
|
-
const
|
|
874
|
-
for (let b = 0; b <
|
|
875
|
-
|
|
871
|
+
const k = filter(i, { _parent: x });
|
|
872
|
+
for (let b = 0; b < k.length; b++)
|
|
873
|
+
k[b]._parent = i[f]._id;
|
|
876
874
|
}
|
|
877
875
|
const p = first(i);
|
|
878
876
|
let u, g;
|
|
879
|
-
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(
|
|
877
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(m = first(i)) == null ? void 0 : m._id]), first(i);
|
|
880
878
|
},
|
|
881
879
|
[r, o, n]
|
|
882
880
|
);
|
|
883
881
|
return { addCoreBlock: useCallback(
|
|
884
882
|
(i, c, d) => {
|
|
885
883
|
if (has(i, "blocks")) {
|
|
886
|
-
const
|
|
887
|
-
return a(
|
|
884
|
+
const k = i.blocks;
|
|
885
|
+
return a(k, c, d);
|
|
888
886
|
}
|
|
889
887
|
const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
|
|
890
888
|
_type: i.type,
|
|
@@ -893,8 +891,8 @@ const undoRedoStateAtom = atom({
|
|
|
893
891
|
...has(i, "_name") && { _name: i._name },
|
|
894
892
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
895
893
|
};
|
|
896
|
-
let
|
|
897
|
-
return c && (
|
|
894
|
+
let h, m;
|
|
895
|
+
return c && (h = find(o, { _id: c }), g._parent = c, m = c), !canAcceptChildBlock(h == null ? void 0 : h._type, g._type) && h && (g._parent = h._parent, m = h._parent), r([g], m, d), n([g._id]), g;
|
|
898
896
|
},
|
|
899
897
|
[r, a, o, n]
|
|
900
898
|
), addPredefinedBlock: a };
|
|
@@ -2334,43 +2332,43 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2334
2332
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2335
2333
|
})
|
|
2336
2334
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2337
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u,
|
|
2338
|
-
const x = cloneDeep(f.find((
|
|
2339
|
-
for (const
|
|
2340
|
-
const b = x[
|
|
2335
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, f) => {
|
|
2336
|
+
const x = cloneDeep(f.find((k) => k._id === m));
|
|
2337
|
+
for (const k in x) {
|
|
2338
|
+
const b = x[k];
|
|
2341
2339
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
2342
2340
|
const { baseClasses: v, classes: B } = getSplitChaiClasses(b);
|
|
2343
|
-
x[
|
|
2341
|
+
x[k] = compact(flattenDeep([v, B])).join(" ");
|
|
2344
2342
|
} else
|
|
2345
|
-
|
|
2343
|
+
k !== "_id" && delete x[k];
|
|
2346
2344
|
}
|
|
2347
2345
|
return x;
|
|
2348
2346
|
};
|
|
2349
2347
|
return {
|
|
2350
2348
|
askAi: useCallback(
|
|
2351
|
-
async (
|
|
2349
|
+
async (m, f, x, k) => {
|
|
2352
2350
|
if (l) {
|
|
2353
2351
|
n(!0), a(null);
|
|
2354
2352
|
try {
|
|
2355
|
-
const b = p === u ? "" : p, v =
|
|
2356
|
-
if (
|
|
2357
|
-
a(
|
|
2353
|
+
const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [h(f, d)], B = await l(m, addLangToPrompt(x, g, m), v, b), { blocks: w, error: _ } = B;
|
|
2354
|
+
if (_) {
|
|
2355
|
+
a(_);
|
|
2358
2356
|
return;
|
|
2359
2357
|
}
|
|
2360
|
-
if (
|
|
2361
|
-
const
|
|
2362
|
-
for (const A in
|
|
2363
|
-
A !== "_id" && (
|
|
2364
|
-
return
|
|
2358
|
+
if (m === "styles") {
|
|
2359
|
+
const E = w.map((C) => {
|
|
2360
|
+
for (const A in C)
|
|
2361
|
+
A !== "_id" && (C[A] = `${STYLES_KEY},${C[A]}`);
|
|
2362
|
+
return C;
|
|
2365
2363
|
});
|
|
2366
|
-
c(
|
|
2364
|
+
c(E);
|
|
2367
2365
|
} else
|
|
2368
2366
|
i(w);
|
|
2369
|
-
|
|
2367
|
+
k && k(B);
|
|
2370
2368
|
} catch (b) {
|
|
2371
2369
|
a(b);
|
|
2372
2370
|
} finally {
|
|
2373
|
-
n(!1),
|
|
2371
|
+
n(!1), k && k();
|
|
2374
2372
|
}
|
|
2375
2373
|
}
|
|
2376
2374
|
},
|
|
@@ -2459,17 +2457,17 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2459
2457
|
r(d), a([]);
|
|
2460
2458
|
const u = {
|
|
2461
2459
|
_chai_copied_blocks: d.flatMap((g) => {
|
|
2462
|
-
const
|
|
2460
|
+
const h = getDuplicatedBlocks(o, g, null);
|
|
2463
2461
|
if (!p)
|
|
2464
|
-
return
|
|
2465
|
-
let
|
|
2466
|
-
for (const f of
|
|
2462
|
+
return h;
|
|
2463
|
+
let m = [];
|
|
2464
|
+
for (const f of h)
|
|
2467
2465
|
if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
|
|
2468
2466
|
let x = l(f.partialBlockId);
|
|
2469
|
-
f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((
|
|
2467
|
+
f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((k) => (isEmpty(k._parent) && set(k, "_parent", f._parent), k))), m = [...m, ...x];
|
|
2470
2468
|
} else
|
|
2471
|
-
|
|
2472
|
-
return
|
|
2469
|
+
m.push(f);
|
|
2470
|
+
return m;
|
|
2473
2471
|
})
|
|
2474
2472
|
};
|
|
2475
2473
|
if (!navigator.clipboard) {
|
|
@@ -2507,13 +2505,13 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2507
2505
|
(a, l = null) => {
|
|
2508
2506
|
const i = [];
|
|
2509
2507
|
each(a, (c) => {
|
|
2510
|
-
const d = o.find((
|
|
2508
|
+
const d = o.find((m) => m._id === c);
|
|
2511
2509
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
2512
2510
|
const g = filter(
|
|
2513
2511
|
o,
|
|
2514
|
-
(
|
|
2515
|
-
).indexOf(d) + 1,
|
|
2516
|
-
r(
|
|
2512
|
+
(m) => isString(l) ? m._parent === l : !m._parent
|
|
2513
|
+
).indexOf(d) + 1, h = getDuplicatedBlocks(o, c, l);
|
|
2514
|
+
r(h, l, g), i.push(get(h, "0._id", ""));
|
|
2517
2515
|
}), n(i);
|
|
2518
2516
|
},
|
|
2519
2517
|
[o, n]
|
|
@@ -2650,13 +2648,13 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2650
2648
|
return map(i, (c) => {
|
|
2651
2649
|
const d = o(c), p = a;
|
|
2652
2650
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2653
|
-
return each(p, (
|
|
2654
|
-
const
|
|
2651
|
+
return each(p, (h) => {
|
|
2652
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2655
2653
|
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2656
|
-
const x = first(
|
|
2657
|
-
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(
|
|
2658
|
-
}), each(p, (
|
|
2659
|
-
const
|
|
2654
|
+
const x = first(h.split(":"));
|
|
2655
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
|
|
2656
|
+
}), each(p, (h) => {
|
|
2657
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2660
2658
|
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2661
2659
|
}), {
|
|
2662
2660
|
ids: [d._id],
|
|
@@ -2740,7 +2738,19 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2740
2738
|
return null;
|
|
2741
2739
|
});
|
|
2742
2740
|
wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
|
|
2743
|
-
const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom),
|
|
2741
|
+
const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), inlineEditingActiveAtom = atom("");
|
|
2742
|
+
inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
|
|
2743
|
+
const inlineEditingItemIndexAtom = atom(0);
|
|
2744
|
+
inlineEditingItemIndexAtom.debugLabel = "inlineEditingItemIndexAtom";
|
|
2745
|
+
const useInlineEditing = () => {
|
|
2746
|
+
const [o, n] = useAtom$1(inlineEditingActiveAtom), [r, a] = useAtom$1(inlineEditingItemIndexAtom);
|
|
2747
|
+
return {
|
|
2748
|
+
editingBlockId: o,
|
|
2749
|
+
editingItemIndex: r,
|
|
2750
|
+
setEditingBlockId: n,
|
|
2751
|
+
setEditingItemIndex: a
|
|
2752
|
+
};
|
|
2753
|
+
}, useSelectedLibrary = () => useAtom$1(selectedLibraryAtom), sidebarActivePanelAtom = atom("outline");
|
|
2744
2754
|
sidebarActivePanelAtom.debugLabel = "sidebarActivePanelAtom";
|
|
2745
2755
|
const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS = [
|
|
2746
2756
|
{ ControlIcon: PinTopIcon, dir: "VERTICAL", key: "UP" },
|
|
@@ -2760,21 +2770,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2760
2770
|
return "VERTICAL";
|
|
2761
2771
|
}
|
|
2762
2772
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
2763
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0,
|
|
2773
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
2764
2774
|
(x) => {
|
|
2765
|
-
isDisabledControl(g,
|
|
2775
|
+
isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
|
|
2766
2776
|
},
|
|
2767
|
-
[g,
|
|
2777
|
+
[g, h, p, u, i, c, n]
|
|
2768
2778
|
);
|
|
2769
2779
|
return useHotkeys(
|
|
2770
2780
|
"shift+up, shift+down, shift+left, shift+right",
|
|
2771
2781
|
({ key: x }) => {
|
|
2772
|
-
var
|
|
2773
|
-
f((
|
|
2782
|
+
var k;
|
|
2783
|
+
f((k = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
|
|
2774
2784
|
},
|
|
2775
2785
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2776
2786
|
[f]
|
|
2777
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock:
|
|
2787
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: f, orientation: m };
|
|
2778
2788
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
2779
2789
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2780
2790
|
o,
|
|
@@ -2810,19 +2820,24 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2810
2820
|
const r = o == null ? void 0 : o.getAttribute("data-block-type");
|
|
2811
2821
|
return !r || o && o.children.length > 0 || r === "Button" ? !1 : INLINE_EDITABLE_BLOCKS.includes(r);
|
|
2812
2822
|
}, useHandleCanvasDblClick = () => {
|
|
2813
|
-
const
|
|
2823
|
+
const { editingBlockId: o, setEditingBlockId: n, setEditingItemIndex: r } = useInlineEditing();
|
|
2814
2824
|
return useCallback(
|
|
2815
|
-
(
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2825
|
+
(a) => {
|
|
2826
|
+
var d;
|
|
2827
|
+
if (a == null || a.preventDefault(), a == null || a.stopPropagation(), o) return;
|
|
2828
|
+
const l = getTargetedBlock(a.target);
|
|
2829
|
+
if (!isInlineEditable(l)) return;
|
|
2830
|
+
const i = l.getAttribute("data-block-id");
|
|
2831
|
+
if (!i || !l) return;
|
|
2832
|
+
const c = l.closest('[data-block-type="Repeater"]');
|
|
2833
|
+
c ? (d = c == null ? void 0 : c.childNodes) == null || d.forEach((p, u) => {
|
|
2834
|
+
p.contains(l) && r(u);
|
|
2835
|
+
}) : r(-1), n(i);
|
|
2821
2836
|
},
|
|
2822
|
-
[o, n]
|
|
2837
|
+
[o, n, r]
|
|
2823
2838
|
);
|
|
2824
2839
|
}, useHandleCanvasClick = () => {
|
|
2825
|
-
const
|
|
2840
|
+
const { editingBlockId: o } = useInlineEditing(), { clearHighlight: n } = useBlockHighlight(), r = useRef(0);
|
|
2826
2841
|
return useCallback(
|
|
2827
2842
|
(a) => {
|
|
2828
2843
|
const l = (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -2844,7 +2859,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2844
2859
|
[o]
|
|
2845
2860
|
);
|
|
2846
2861
|
}, useHandleMouseMove = () => {
|
|
2847
|
-
const
|
|
2862
|
+
const { editingBlockId: o } = useInlineEditing(), { highlightBlock: n } = useBlockHighlight();
|
|
2848
2863
|
return useThrottledCallback(
|
|
2849
2864
|
(r) => {
|
|
2850
2865
|
if (o) return;
|
|
@@ -2909,27 +2924,27 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2909
2924
|
i([null]);
|
|
2910
2925
|
}, [r, n]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
|
|
2911
2926
|
}, BlockFloatingSelector = ({ block: o, selectedBlockElement: n }) => {
|
|
2912
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(),
|
|
2927
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: g, refs: h, update: m } = useFloating({
|
|
2913
2928
|
placement: "top-start",
|
|
2914
2929
|
middleware: [shift(), flip()],
|
|
2915
2930
|
elements: { reference: n }
|
|
2916
2931
|
});
|
|
2917
|
-
useResizeObserver(n, () =>
|
|
2932
|
+
useResizeObserver(n, () => m(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
|
|
2918
2933
|
const f = get(o, "_parent", null), x = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
2919
2934
|
return !n || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
2920
2935
|
"div",
|
|
2921
2936
|
{
|
|
2922
2937
|
role: "button",
|
|
2923
2938
|
tabIndex: 0,
|
|
2924
|
-
ref:
|
|
2939
|
+
ref: h.setFloating,
|
|
2925
2940
|
style: g,
|
|
2926
|
-
onClick: (
|
|
2927
|
-
|
|
2941
|
+
onClick: (k) => {
|
|
2942
|
+
k.stopPropagation(), k.preventDefault();
|
|
2928
2943
|
},
|
|
2929
|
-
onMouseEnter: (
|
|
2930
|
-
|
|
2944
|
+
onMouseEnter: (k) => {
|
|
2945
|
+
k.stopPropagation(), i(null);
|
|
2931
2946
|
},
|
|
2932
|
-
onKeyDown: (
|
|
2947
|
+
onKeyDown: (k) => k.stopPropagation(),
|
|
2933
2948
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
2934
2949
|
children: [
|
|
2935
2950
|
f && /* @__PURE__ */ jsx(
|
|
@@ -2946,7 +2961,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2946
2961
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
2947
2962
|
canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
|
|
2948
2963
|
canDeleteBlock(get(o, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([o == null ? void 0 : o._id]) }) : null,
|
|
2949
|
-
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar:
|
|
2964
|
+
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: m })
|
|
2950
2965
|
] })
|
|
2951
2966
|
]
|
|
2952
2967
|
}
|
|
@@ -3079,15 +3094,15 @@ H(Frame, "defaultProps", {
|
|
|
3079
3094
|
initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
|
|
3080
3095
|
});
|
|
3081
3096
|
const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
|
|
3082
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks:
|
|
3097
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
|
|
3083
3098
|
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
|
|
3084
3099
|
"ctrl+v,command+v",
|
|
3085
3100
|
() => {
|
|
3086
|
-
g(n[0]) &&
|
|
3101
|
+
g(n[0]) && h(n);
|
|
3087
3102
|
},
|
|
3088
|
-
{ ...
|
|
3089
|
-
[n, g,
|
|
3090
|
-
), useHotkeys("esc", () => r([]),
|
|
3103
|
+
{ ...m, preventDefault: !0 },
|
|
3104
|
+
[n, g, h]
|
|
3105
|
+
), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, preventDefault: !0 }, [
|
|
3091
3106
|
n,
|
|
3092
3107
|
i
|
|
3093
3108
|
]), useHotkeys(
|
|
@@ -3095,7 +3110,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3095
3110
|
(f) => {
|
|
3096
3111
|
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3097
3112
|
},
|
|
3098
|
-
|
|
3113
|
+
m,
|
|
3099
3114
|
[n, l]
|
|
3100
3115
|
);
|
|
3101
3116
|
}, KeyboardHandler = () => {
|
|
@@ -3386,8 +3401,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3386
3401
|
],
|
|
3387
3402
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3388
3403
|
onBlur: ({ editor: u, event: g }) => {
|
|
3389
|
-
const
|
|
3390
|
-
if (!x && !
|
|
3404
|
+
const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = m == null ? void 0 : m.contains(h), k = f == null ? void 0 : f.contains(h);
|
|
3405
|
+
if (!x && !k) {
|
|
3391
3406
|
const b = (u == null ? void 0 : u.getHTML()) || "";
|
|
3392
3407
|
r(b);
|
|
3393
3408
|
}
|
|
@@ -3404,10 +3419,10 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3404
3419
|
});
|
|
3405
3420
|
}, [c]);
|
|
3406
3421
|
const d = useMemo(() => {
|
|
3407
|
-
var
|
|
3422
|
+
var h;
|
|
3408
3423
|
const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
|
|
3409
3424
|
if (!n) return u;
|
|
3410
|
-
const g = ((
|
|
3425
|
+
const g = ((h = n == null ? void 0 : n.className) == null ? void 0 : h.replace("sr-only", "")) || "";
|
|
3411
3426
|
return `${u} ${g}`;
|
|
3412
3427
|
}, [n]), p = useCallback(
|
|
3413
3428
|
(u) => {
|
|
@@ -3442,28 +3457,28 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3442
3457
|
useEffect(() => {
|
|
3443
3458
|
if (a.current) {
|
|
3444
3459
|
a.current.innerText = n, a.current.focus();
|
|
3445
|
-
const
|
|
3446
|
-
|
|
3460
|
+
const m = c.createRange(), f = d.getSelection();
|
|
3461
|
+
m.selectNodeContents(a.current), m.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(m), a.current.focus();
|
|
3447
3462
|
} else
|
|
3448
3463
|
r();
|
|
3449
3464
|
}, [c, d]);
|
|
3450
3465
|
const p = useMemo(() => {
|
|
3451
3466
|
var f;
|
|
3452
|
-
const
|
|
3453
|
-
return
|
|
3467
|
+
const m = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
|
|
3468
|
+
return m === "button" ? "div" : m;
|
|
3454
3469
|
}, [o]), u = useCallback(
|
|
3455
|
-
(
|
|
3456
|
-
(
|
|
3470
|
+
(m) => {
|
|
3471
|
+
(m.key === "Enter" || m.key === "Escape") && i(m);
|
|
3457
3472
|
},
|
|
3458
3473
|
[i]
|
|
3459
3474
|
), g = useCallback(() => {
|
|
3460
3475
|
r();
|
|
3461
|
-
}, [r]),
|
|
3462
|
-
var
|
|
3476
|
+
}, [r]), h = useMemo(() => {
|
|
3477
|
+
var m;
|
|
3463
3478
|
return {
|
|
3464
3479
|
id: "active-inline-editing-element",
|
|
3465
3480
|
contentEditable: !0,
|
|
3466
|
-
className: `${((
|
|
3481
|
+
className: `${((m = o == null ? void 0 : o.className) == null ? void 0 : m.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
|
|
3467
3482
|
style: cloneDeep(o == null ? void 0 : o.style) || {},
|
|
3468
3483
|
onInput: (f) => {
|
|
3469
3484
|
const x = f.target;
|
|
@@ -3478,67 +3493,67 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3478
3493
|
ref: a,
|
|
3479
3494
|
onBlur: g,
|
|
3480
3495
|
onKeyDown: u,
|
|
3481
|
-
...
|
|
3496
|
+
...h
|
|
3482
3497
|
}) });
|
|
3483
3498
|
}
|
|
3484
3499
|
), WithBlockTextEditor = memo(
|
|
3485
3500
|
({ block: o, children: n }) => {
|
|
3486
|
-
const r = "content", { document: a } = useFrame(),
|
|
3487
|
-
var
|
|
3488
|
-
const
|
|
3489
|
-
let
|
|
3490
|
-
const
|
|
3491
|
-
return
|
|
3492
|
-
}, [o,
|
|
3493
|
-
(
|
|
3494
|
-
var
|
|
3495
|
-
const
|
|
3496
|
-
|
|
3501
|
+
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), k = useRef(null), b = l, { blockContent: v, blockType: B } = useMemo(() => {
|
|
3502
|
+
var j;
|
|
3503
|
+
const A = o._type;
|
|
3504
|
+
let N = o[r];
|
|
3505
|
+
const S = getRegisteredChaiBlock(o._type);
|
|
3506
|
+
return f && ((j = S == null ? void 0 : S.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${f}`) && (N = get(o, `${r}-${f}`)), { blockContent: N, blockType: A };
|
|
3507
|
+
}, [o, f]), w = useCallback(
|
|
3508
|
+
(A) => {
|
|
3509
|
+
var S;
|
|
3510
|
+
const N = A || ((S = g.current) == null ? void 0 : S.innerText);
|
|
3511
|
+
m([b], { [r]: N }), u(null), c(null), d(-1), x([]);
|
|
3497
3512
|
},
|
|
3498
|
-
[
|
|
3499
|
-
),
|
|
3500
|
-
(
|
|
3501
|
-
|
|
3513
|
+
[b, m, c, x, f]
|
|
3514
|
+
), _ = useDebouncedCallback(
|
|
3515
|
+
(A) => {
|
|
3516
|
+
m([b], { [r]: A });
|
|
3502
3517
|
},
|
|
3503
|
-
[
|
|
3518
|
+
[b, o, m, f],
|
|
3504
3519
|
1e3
|
|
3505
|
-
),
|
|
3506
|
-
(
|
|
3507
|
-
|
|
3508
|
-
const
|
|
3509
|
-
|
|
3520
|
+
), E = useCallback(
|
|
3521
|
+
(A) => {
|
|
3522
|
+
A.preventDefault(), b && (k.current = b), w(), setTimeout(() => {
|
|
3523
|
+
const N = k.current;
|
|
3524
|
+
k.current = null, x([N]);
|
|
3510
3525
|
}, 100);
|
|
3511
3526
|
},
|
|
3512
|
-
[
|
|
3527
|
+
[x, b, f]
|
|
3513
3528
|
);
|
|
3514
3529
|
useEffect(() => {
|
|
3515
|
-
var
|
|
3516
|
-
if (!
|
|
3517
|
-
const
|
|
3518
|
-
|
|
3519
|
-
}, [
|
|
3520
|
-
const
|
|
3530
|
+
var y;
|
|
3531
|
+
if (!b) return;
|
|
3532
|
+
const A = `[data-block-id="${b}"]`, N = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${A}${N}`);
|
|
3533
|
+
S && ((y = S == null ? void 0 : S.classList) == null || y.add("sr-only"), u(S));
|
|
3534
|
+
}, [b, B, a, i]);
|
|
3535
|
+
const C = useMemo(() => p ? (h(), B === "RichText" ? /* @__PURE__ */ jsx(
|
|
3521
3536
|
RichTextEditor,
|
|
3522
3537
|
{
|
|
3523
|
-
blockContent:
|
|
3524
|
-
editingElement:
|
|
3525
|
-
onChange:
|
|
3526
|
-
onClose:
|
|
3527
|
-
onEscape:
|
|
3538
|
+
blockContent: v,
|
|
3539
|
+
editingElement: p,
|
|
3540
|
+
onChange: _,
|
|
3541
|
+
onClose: w,
|
|
3542
|
+
onEscape: E
|
|
3528
3543
|
}
|
|
3529
3544
|
) : /* @__PURE__ */ jsx(
|
|
3530
3545
|
MemoizedEditor,
|
|
3531
3546
|
{
|
|
3532
|
-
editorRef:
|
|
3533
|
-
blockContent:
|
|
3534
|
-
editingElement:
|
|
3535
|
-
onClose:
|
|
3536
|
-
onChange:
|
|
3537
|
-
onEscape:
|
|
3547
|
+
editorRef: g,
|
|
3548
|
+
blockContent: v,
|
|
3549
|
+
editingElement: p,
|
|
3550
|
+
onClose: w,
|
|
3551
|
+
onChange: _,
|
|
3552
|
+
onEscape: E
|
|
3538
3553
|
}
|
|
3539
|
-
)) : null, [
|
|
3554
|
+
)) : null, [p, b, B, v, w, f]);
|
|
3540
3555
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3541
|
-
|
|
3556
|
+
C,
|
|
3542
3557
|
n
|
|
3543
3558
|
] });
|
|
3544
3559
|
},
|
|
@@ -3571,52 +3586,52 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3571
3586
|
blockAtom: n,
|
|
3572
3587
|
children: r
|
|
3573
3588
|
}) => {
|
|
3574
|
-
const
|
|
3575
|
-
() => m ? applyBindingToBlockProps(applyLanguage(
|
|
3576
|
-
index:
|
|
3577
|
-
key:
|
|
3578
|
-
}) : applyLanguage(
|
|
3579
|
-
[
|
|
3580
|
-
),
|
|
3581
|
-
() =>
|
|
3582
|
-
[
|
|
3583
|
-
),
|
|
3589
|
+
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), f = get(c, "component", null), { index: x, key: k } = useContext(RepeaterContext), b = useMemo(
|
|
3590
|
+
() => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
3591
|
+
index: x,
|
|
3592
|
+
key: k
|
|
3593
|
+
}) : applyLanguage(i, d, c),
|
|
3594
|
+
[i, d, c, g, m, x, k]
|
|
3595
|
+
), v = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), B = useMemo(
|
|
3596
|
+
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
3597
|
+
[i._id, i._type, u, getBlockRuntimeProps]
|
|
3598
|
+
), w = useMemo(
|
|
3584
3599
|
() => ({
|
|
3585
|
-
blockProps: { "data-block-id":
|
|
3600
|
+
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": x },
|
|
3586
3601
|
inBuilder: !0,
|
|
3587
|
-
lang:
|
|
3588
|
-
...y,
|
|
3602
|
+
lang: d || p,
|
|
3589
3603
|
...b,
|
|
3590
3604
|
...v,
|
|
3605
|
+
...B,
|
|
3591
3606
|
...o
|
|
3592
3607
|
}),
|
|
3593
3608
|
[
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
c,
|
|
3609
|
+
i._id,
|
|
3610
|
+
i._type,
|
|
3597
3611
|
d,
|
|
3598
|
-
|
|
3612
|
+
p,
|
|
3599
3613
|
b,
|
|
3600
3614
|
v,
|
|
3615
|
+
B,
|
|
3601
3616
|
o
|
|
3602
3617
|
]
|
|
3603
|
-
),
|
|
3604
|
-
if (isNull(
|
|
3605
|
-
let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(
|
|
3606
|
-
...
|
|
3618
|
+
), _ = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
|
|
3619
|
+
if (isNull(f) || h.includes(i._id)) return null;
|
|
3620
|
+
let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(f, {
|
|
3621
|
+
...w,
|
|
3607
3622
|
children: r({
|
|
3608
|
-
_id:
|
|
3609
|
-
_type:
|
|
3610
|
-
...isArray(
|
|
3611
|
-
repeaterItems: applyLimit(
|
|
3612
|
-
$repeaterItemsKey:
|
|
3623
|
+
_id: i._id,
|
|
3624
|
+
_type: i._type,
|
|
3625
|
+
...isArray(b.repeaterItems) ? {
|
|
3626
|
+
repeaterItems: applyLimit(b.repeaterItems, i),
|
|
3627
|
+
$repeaterItemsKey: b.$repeaterItemsKey
|
|
3613
3628
|
} : {},
|
|
3614
|
-
...
|
|
3615
|
-
...
|
|
3629
|
+
...i.partialBlockId ? { partialBlockId: i.partialBlockId } : "",
|
|
3630
|
+
...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
|
|
3616
3631
|
})
|
|
3617
3632
|
}) });
|
|
3618
|
-
const
|
|
3619
|
-
return
|
|
3633
|
+
const C = a === i._id && (l === x || x < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: E }) : E;
|
|
3634
|
+
return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: C }) : C;
|
|
3620
3635
|
}, PartialBlocksRenderer = ({ partialBlockId: o }) => {
|
|
3621
3636
|
const { getPartailBlocks: n } = usePartialBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom(r)), [r]);
|
|
3622
3637
|
return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
|
|
@@ -3634,7 +3649,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3634
3649
|
);
|
|
3635
3650
|
return map(l, (c) => {
|
|
3636
3651
|
const d = a(c._id);
|
|
3637
|
-
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId:
|
|
3652
|
+
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: f }) => g === "Repeater" ? isArray(m) && m.map((x, k) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: k, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) }, `${u}-${k}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
|
|
3638
3653
|
});
|
|
3639
3654
|
}, PageBlocksRenderer = () => {
|
|
3640
3655
|
const [o] = useBlocksStore();
|
|
@@ -3648,11 +3663,11 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3648
3663
|
if (d < n) {
|
|
3649
3664
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
3650
3665
|
let g = {};
|
|
3651
|
-
const
|
|
3666
|
+
const h = p * u, m = d * u;
|
|
3652
3667
|
p && (g = {
|
|
3653
3668
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3654
|
-
height: 100 + (p -
|
|
3655
|
-
width: 100 + (d -
|
|
3669
|
+
height: 100 + (p - h) / h * 100 + "%",
|
|
3670
|
+
width: 100 + (d - m) / m * 100 + "%"
|
|
3656
3671
|
}), i({
|
|
3657
3672
|
position: "relative",
|
|
3658
3673
|
top: 0,
|
|
@@ -3701,19 +3716,19 @@ const CanvasEventsWatcher = () => {
|
|
|
3701
3716
|
}), null;
|
|
3702
3717
|
}, StaticCanvas = () => {
|
|
3703
3718
|
const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
|
|
3704
|
-
(
|
|
3705
|
-
i((f) => ({ ...f, width:
|
|
3719
|
+
(m) => {
|
|
3720
|
+
i((f) => ({ ...f, width: m }));
|
|
3706
3721
|
},
|
|
3707
3722
|
[i]
|
|
3708
3723
|
);
|
|
3709
3724
|
useEffect(() => {
|
|
3710
3725
|
if (!a.current) return;
|
|
3711
|
-
const { clientWidth:
|
|
3712
|
-
i({ width:
|
|
3726
|
+
const { clientWidth: m, clientHeight: f } = a.current;
|
|
3727
|
+
i({ width: m, height: f });
|
|
3713
3728
|
}, [a, o]);
|
|
3714
|
-
const
|
|
3715
|
-
let
|
|
3716
|
-
return
|
|
3729
|
+
const h = useMemo(() => {
|
|
3730
|
+
let m = IframeInitialContent;
|
|
3731
|
+
return m = m.replace("__HTML_DIR__", u), m;
|
|
3717
3732
|
}, [u]);
|
|
3718
3733
|
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: g, onResize: g, children: /* @__PURE__ */ jsx(
|
|
3719
3734
|
"div",
|
|
@@ -3729,7 +3744,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3729
3744
|
id: "canvas-iframe",
|
|
3730
3745
|
style: { ...c, ...isEmpty(c) ? { width: `${o}px` } : {} },
|
|
3731
3746
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
3732
|
-
initialContent:
|
|
3747
|
+
initialContent: h,
|
|
3733
3748
|
children: [
|
|
3734
3749
|
/* @__PURE__ */ jsx(KeyboardHandler, {}),
|
|
3735
3750
|
/* @__PURE__ */ jsx(BlockSelectionHighlighter, {}),
|
|
@@ -3824,7 +3839,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3824
3839
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
|
|
3825
3840
|
] });
|
|
3826
3841
|
}, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
|
|
3827
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null),
|
|
3842
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (f) => {
|
|
3828
3843
|
if (!f.trim()) {
|
|
3829
3844
|
p(!1), g("Please enter a URL");
|
|
3830
3845
|
return;
|
|
@@ -3836,9 +3851,9 @@ const CanvasEventsWatcher = () => {
|
|
|
3836
3851
|
} finally {
|
|
3837
3852
|
c(!1);
|
|
3838
3853
|
}
|
|
3839
|
-
}, { t:
|
|
3854
|
+
}, { t: m } = useTranslation();
|
|
3840
3855
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-96 flex-col gap-4 p-4", children: [
|
|
3841
|
-
/* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children:
|
|
3856
|
+
/* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: m(`${r.charAt(0).toUpperCase() + r.slice(1)} Manager`) }),
|
|
3842
3857
|
u && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
|
|
3843
3858
|
/* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
|
|
3844
3859
|
/* @__PURE__ */ jsx(AlertDescription, { children: u })
|
|
@@ -3847,20 +3862,20 @@ const CanvasEventsWatcher = () => {
|
|
|
3847
3862
|
/* @__PURE__ */ jsx(
|
|
3848
3863
|
Input$1,
|
|
3849
3864
|
{
|
|
3850
|
-
placeholder:
|
|
3865
|
+
placeholder: m(`Enter ${r} URL`),
|
|
3851
3866
|
value: a,
|
|
3852
3867
|
onChange: (f) => l(f.target.value),
|
|
3853
|
-
onKeyUp: () =>
|
|
3868
|
+
onKeyUp: () => h(a)
|
|
3854
3869
|
}
|
|
3855
3870
|
),
|
|
3856
3871
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
3857
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: o, children:
|
|
3872
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: o, children: m("Cancel") }),
|
|
3858
3873
|
/* @__PURE__ */ jsx(
|
|
3859
3874
|
Button,
|
|
3860
3875
|
{
|
|
3861
3876
|
onClick: () => n({ id: "dam-id", url: a, width: 600, height: 400, description: "This is image description" }),
|
|
3862
3877
|
disabled: !d || i,
|
|
3863
|
-
children:
|
|
3878
|
+
children: m("Insert")
|
|
3864
3879
|
}
|
|
3865
3880
|
)
|
|
3866
3881
|
] })
|
|
@@ -3887,16 +3902,16 @@ const CanvasEventsWatcher = () => {
|
|
|
3887
3902
|
MediaManagerModal.displayName = "MediaManagerModal";
|
|
3888
3903
|
const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
3889
3904
|
const { t: l } = useTranslation(), i = useSelectedBlock(), c = useUpdateBlocksProps(), d = (g) => {
|
|
3890
|
-
const
|
|
3891
|
-
if (
|
|
3892
|
-
n(
|
|
3893
|
-
const
|
|
3905
|
+
const h = isArray(g) ? first(g) : g;
|
|
3906
|
+
if (h) {
|
|
3907
|
+
n(h == null ? void 0 : h.url);
|
|
3908
|
+
const m = h == null ? void 0 : h.width, f = h == null ? void 0 : h.height;
|
|
3894
3909
|
if (i != null && i._id) {
|
|
3895
3910
|
const x = {
|
|
3896
|
-
...
|
|
3911
|
+
...m && { width: m },
|
|
3897
3912
|
...f && { height: f },
|
|
3898
|
-
...
|
|
3899
|
-
...
|
|
3913
|
+
...h.description && { alt: h.description },
|
|
3914
|
+
...h.id && { assetId: h.id }
|
|
3900
3915
|
};
|
|
3901
3916
|
if (isEmpty(x)) return;
|
|
3902
3917
|
c([i._id], x);
|
|
@@ -3941,18 +3956,18 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
3941
3956
|
] })
|
|
3942
3957
|
] });
|
|
3943
3958
|
}, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
|
|
3944
|
-
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (
|
|
3945
|
-
(
|
|
3946
|
-
const
|
|
3947
|
-
|
|
3959
|
+
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", p = React__default.useCallback(
|
|
3960
|
+
(h) => {
|
|
3961
|
+
const m = (f) => r === "value" ? f === "value" || f === "object" : r === "array" ? f === "array" : f === r;
|
|
3962
|
+
h.type === "object" ? (l((f) => [...f, h.key]), c(h.value)) : m(h.type) && n([...a, h.key].join("."), r);
|
|
3948
3963
|
},
|
|
3949
3964
|
[a, n, r]
|
|
3950
3965
|
), u = React__default.useCallback(() => {
|
|
3951
3966
|
if (a.length > 0) {
|
|
3952
|
-
const
|
|
3953
|
-
l(
|
|
3967
|
+
const h = a.slice(0, -1);
|
|
3968
|
+
l(h), c(h.reduce((m, f) => m[f], o));
|
|
3954
3969
|
}
|
|
3955
|
-
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([
|
|
3970
|
+
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([h, m]) => ({ key: h, value: m, type: d(m) })).filter((h) => !startsWith(h.key, REPEATER_PREFIX) && h.key.includes("/") ? !1 : r === "value" ? h.type === "value" || h.type === "object" : r === "array" ? h.type === "array" || h.type === "object" : r === "object" ? h.type === "object" : !0) : [], [i, r]);
|
|
3956
3971
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
3957
3972
|
/* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
|
|
3958
3973
|
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
@@ -3962,36 +3977,36 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
3962
3977
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
3963
3978
|
"Back"
|
|
3964
3979
|
] }),
|
|
3965
|
-
g.map((
|
|
3980
|
+
g.map((h) => /* @__PURE__ */ jsxs(
|
|
3966
3981
|
CommandItem,
|
|
3967
3982
|
{
|
|
3968
|
-
value:
|
|
3983
|
+
value: h.key,
|
|
3969
3984
|
disabled: !1,
|
|
3970
|
-
onSelect: () => p(
|
|
3985
|
+
onSelect: () => p(h),
|
|
3971
3986
|
className: "flex items-center justify-between",
|
|
3972
3987
|
children: [
|
|
3973
3988
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
|
|
3974
|
-
startsWith(
|
|
3975
|
-
startsWith(
|
|
3989
|
+
startsWith(h.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(h.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(DatabaseIcon, {}) : null,
|
|
3990
|
+
startsWith(h.key, REPEATER_PREFIX) ? "Repeater Data" : startsWith(h.key, COLLECTION_PREFIX) ? h.key.replace(COLLECTION_PREFIX, "") : h.key
|
|
3976
3991
|
] }),
|
|
3977
3992
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3978
|
-
r === "object" &&
|
|
3993
|
+
r === "object" && h.type === "object" && /* @__PURE__ */ jsx(
|
|
3979
3994
|
Button,
|
|
3980
3995
|
{
|
|
3981
3996
|
size: "sm",
|
|
3982
3997
|
variant: "ghost",
|
|
3983
3998
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
3984
|
-
onClick: (
|
|
3985
|
-
|
|
3999
|
+
onClick: (m) => {
|
|
4000
|
+
m.stopPropagation(), n([...a, h.key].join("."), r);
|
|
3986
4001
|
},
|
|
3987
4002
|
children: "Select"
|
|
3988
4003
|
}
|
|
3989
4004
|
),
|
|
3990
|
-
|
|
4005
|
+
h.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" }) })
|
|
3991
4006
|
] })
|
|
3992
4007
|
]
|
|
3993
4008
|
},
|
|
3994
|
-
|
|
4009
|
+
h.key
|
|
3995
4010
|
))
|
|
3996
4011
|
] })
|
|
3997
4012
|
] })
|
|
@@ -4043,27 +4058,27 @@ const DataBindingSelector = ({
|
|
|
4043
4058
|
}) => {
|
|
4044
4059
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4045
4060
|
if (i.length === 1) return "";
|
|
4046
|
-
const g = i.find((f) => f._type === "Repeater"),
|
|
4047
|
-
return `${REPEATER_PREFIX}${startsWith(
|
|
4061
|
+
const g = i.find((f) => f._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4062
|
+
return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${g._id}` : m}`;
|
|
4048
4063
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4049
|
-
(g,
|
|
4050
|
-
if (g = isEmpty(d) ? g : g.replace(`${d}`, "$index"),
|
|
4064
|
+
(g, h) => {
|
|
4065
|
+
if (g = isEmpty(d) ? g : g.replace(`${d}`, "$index"), h === "array" || h === "object") {
|
|
4051
4066
|
n(`{{${g}}}`, {}, r);
|
|
4052
4067
|
return;
|
|
4053
4068
|
}
|
|
4054
|
-
const
|
|
4055
|
-
let w = "",
|
|
4056
|
-
const
|
|
4057
|
-
return v > 0 && (
|
|
4058
|
-
text: w + B +
|
|
4069
|
+
const m = (b) => /[.,!?;:]/.test(b), f = (b, v, B) => {
|
|
4070
|
+
let w = "", _ = "";
|
|
4071
|
+
const E = v > 0 ? b[v - 1] : "", C = v < b.length ? b[v] : "";
|
|
4072
|
+
return v > 0 && (E === "." || !m(E) && E !== " ") && (w = " "), v < b.length && !m(C) && C !== " " && (_ = " "), {
|
|
4073
|
+
text: w + B + _,
|
|
4059
4074
|
prefixLength: w.length,
|
|
4060
|
-
suffixLength:
|
|
4075
|
+
suffixLength: _.length
|
|
4061
4076
|
};
|
|
4062
4077
|
}, x = document.getElementById(r);
|
|
4063
4078
|
if (!x) return;
|
|
4064
|
-
const
|
|
4065
|
-
if (
|
|
4066
|
-
const b =
|
|
4079
|
+
const k = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
|
|
4080
|
+
if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
|
|
4081
|
+
const b = k.__chaiRTE;
|
|
4067
4082
|
if (b) {
|
|
4068
4083
|
const v = `{{${g}}}`;
|
|
4069
4084
|
b.commands.focus();
|
|
@@ -4071,11 +4086,11 @@ const DataBindingSelector = ({
|
|
|
4071
4086
|
if (B !== w)
|
|
4072
4087
|
b.chain().deleteSelection().insertContent(v).run();
|
|
4073
4088
|
else {
|
|
4074
|
-
const { state:
|
|
4075
|
-
let
|
|
4076
|
-
|
|
4077
|
-
let
|
|
4078
|
-
N && N !== " " && !
|
|
4089
|
+
const { state: E } = b, C = E.selection.from, A = E.doc.textBetween(Math.max(0, C - 1), C), N = E.doc.textBetween(C, Math.min(C + 1, E.doc.content.size));
|
|
4090
|
+
let S = "";
|
|
4091
|
+
C > 0 && A !== " " && !m(A) && (S = " ");
|
|
4092
|
+
let y = "";
|
|
4093
|
+
N && N !== " " && !m(N) && (y = " "), b.chain().insertContent(S + v + y).run();
|
|
4079
4094
|
}
|
|
4080
4095
|
setTimeout(() => n(b.getHTML(), {}, r), 100);
|
|
4081
4096
|
return;
|
|
@@ -4083,11 +4098,11 @@ const DataBindingSelector = ({
|
|
|
4083
4098
|
} else {
|
|
4084
4099
|
const b = x, v = b.selectionStart || 0, B = b.value || "", w = b.selectionEnd || v;
|
|
4085
4100
|
if (w > v) {
|
|
4086
|
-
const N = `{{${g}}}`, { text:
|
|
4087
|
-
n(
|
|
4101
|
+
const N = `{{${g}}}`, { text: S } = f(B, v, N), y = B.slice(0, v) + S + B.slice(w);
|
|
4102
|
+
n(y, {}, r);
|
|
4088
4103
|
return;
|
|
4089
4104
|
}
|
|
4090
|
-
const
|
|
4105
|
+
const E = `{{${g}}}`, { text: C } = f(B, v, E), A = B.slice(0, v) + C + B.slice(v);
|
|
4091
4106
|
n(A, {}, r);
|
|
4092
4107
|
}
|
|
4093
4108
|
},
|
|
@@ -4110,73 +4125,73 @@ const DataBindingSelector = ({
|
|
|
4110
4125
|
onChange: r
|
|
4111
4126
|
}) => {
|
|
4112
4127
|
var N;
|
|
4113
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (
|
|
4128
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [k, b] = useState(-1), v = useRef(null), B = (N = n == null ? void 0 : n.find((S) => S.key === u)) == null ? void 0 : N.name;
|
|
4114
4129
|
useEffect(() => {
|
|
4115
|
-
if (
|
|
4116
|
-
const
|
|
4117
|
-
g(
|
|
4118
|
-
const j = await l(
|
|
4119
|
-
j && Array.isArray(j) &&
|
|
4130
|
+
if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4131
|
+
const S = split(o, ":"), y = get(S, 1, "page") || "page";
|
|
4132
|
+
g(y), (async () => {
|
|
4133
|
+
const j = await l(y, [get(S, 2, "page")]);
|
|
4134
|
+
j && Array.isArray(j) && m(get(j, [0, "name"], ""));
|
|
4120
4135
|
})();
|
|
4121
4136
|
}, [o]);
|
|
4122
4137
|
const w = useDebouncedCallback(
|
|
4123
|
-
async (
|
|
4124
|
-
if (isEmpty(
|
|
4138
|
+
async (S) => {
|
|
4139
|
+
if (isEmpty(S))
|
|
4125
4140
|
x([]);
|
|
4126
4141
|
else {
|
|
4127
|
-
const
|
|
4128
|
-
x(
|
|
4142
|
+
const y = await l(u, S);
|
|
4143
|
+
x(y);
|
|
4129
4144
|
}
|
|
4130
4145
|
c(!1), b(-1);
|
|
4131
4146
|
},
|
|
4132
4147
|
[u],
|
|
4133
4148
|
300
|
|
4134
|
-
),
|
|
4135
|
-
const
|
|
4136
|
-
|
|
4137
|
-
},
|
|
4138
|
-
switch (
|
|
4149
|
+
), _ = (S) => {
|
|
4150
|
+
const y = ["pageType", u, S.id];
|
|
4151
|
+
y[1] && (r(y.join(":")), m(S.name), p(!1), x([]), b(-1));
|
|
4152
|
+
}, E = (S) => {
|
|
4153
|
+
switch (S.key) {
|
|
4139
4154
|
case "ArrowDown":
|
|
4140
|
-
|
|
4155
|
+
S.preventDefault(), b((y) => y < f.length - 1 ? y + 1 : y);
|
|
4141
4156
|
break;
|
|
4142
4157
|
case "ArrowUp":
|
|
4143
|
-
|
|
4158
|
+
S.preventDefault(), b((y) => y > 0 ? y - 1 : y);
|
|
4144
4159
|
break;
|
|
4145
4160
|
case "Enter":
|
|
4146
|
-
if (
|
|
4147
|
-
|
|
4161
|
+
if (S.preventDefault(), f.length === 0) return;
|
|
4162
|
+
k >= 0 && _(f[k]);
|
|
4148
4163
|
break;
|
|
4149
4164
|
case "Escape":
|
|
4150
|
-
|
|
4165
|
+
S.preventDefault(), C();
|
|
4151
4166
|
break;
|
|
4152
4167
|
}
|
|
4153
4168
|
};
|
|
4154
4169
|
useEffect(() => {
|
|
4155
|
-
if (
|
|
4156
|
-
const
|
|
4157
|
-
|
|
4170
|
+
if (k >= 0 && v.current) {
|
|
4171
|
+
const S = v.current.children[k];
|
|
4172
|
+
S == null || S.scrollIntoView({ block: "nearest" });
|
|
4158
4173
|
}
|
|
4159
|
-
}, [
|
|
4160
|
-
const
|
|
4161
|
-
|
|
4162
|
-
}, A = (
|
|
4163
|
-
|
|
4174
|
+
}, [k]);
|
|
4175
|
+
const C = () => {
|
|
4176
|
+
m(""), x([]), b(-1), p(!1), r("");
|
|
4177
|
+
}, A = (S) => {
|
|
4178
|
+
m(S), p(!isEmpty(S)), c(!0), w(S);
|
|
4164
4179
|
};
|
|
4165
4180
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4166
|
-
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (
|
|
4181
|
+
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (S) => g(S.target.value), children: map(n, (S) => /* @__PURE__ */ jsx("option", { value: S.key, children: S.name }, S.key)) }),
|
|
4167
4182
|
u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
|
|
4168
4183
|
/* @__PURE__ */ jsx(
|
|
4169
4184
|
"input",
|
|
4170
4185
|
{
|
|
4171
4186
|
type: "text",
|
|
4172
|
-
value:
|
|
4173
|
-
onChange: (
|
|
4174
|
-
onKeyDown:
|
|
4187
|
+
value: h,
|
|
4188
|
+
onChange: (S) => A(S.target.value),
|
|
4189
|
+
onKeyDown: E,
|
|
4175
4190
|
placeholder: a(`Search ${B ?? ""}`),
|
|
4176
4191
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4177
4192
|
}
|
|
4178
4193
|
),
|
|
4179
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children:
|
|
4194
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: C, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4180
4195
|
] }),
|
|
4181
4196
|
(i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4182
4197
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
@@ -4184,24 +4199,24 @@ const DataBindingSelector = ({
|
|
|
4184
4199
|
] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4185
4200
|
a("No results found for"),
|
|
4186
4201
|
' "',
|
|
4187
|
-
|
|
4202
|
+
h,
|
|
4188
4203
|
'"'
|
|
4189
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (
|
|
4204
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (S, y) => /* @__PURE__ */ jsxs(
|
|
4190
4205
|
"li",
|
|
4191
4206
|
{
|
|
4192
|
-
onClick: () =>
|
|
4193
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(
|
|
4207
|
+
onClick: () => _(S),
|
|
4208
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(S.id) ? "bg-blue-200" : y === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4194
4209
|
children: [
|
|
4195
|
-
|
|
4210
|
+
S.name,
|
|
4196
4211
|
" ",
|
|
4197
|
-
|
|
4212
|
+
S.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
|
|
4198
4213
|
"( ",
|
|
4199
|
-
|
|
4214
|
+
S.slug,
|
|
4200
4215
|
" )"
|
|
4201
4216
|
] })
|
|
4202
4217
|
]
|
|
4203
4218
|
},
|
|
4204
|
-
|
|
4219
|
+
S.id
|
|
4205
4220
|
)) }) })
|
|
4206
4221
|
] });
|
|
4207
4222
|
}, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
|
|
@@ -4442,16 +4457,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4442
4457
|
const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
|
|
4443
4458
|
useEffect(() => {
|
|
4444
4459
|
if (o) {
|
|
4445
|
-
const
|
|
4446
|
-
return
|
|
4460
|
+
const h = document.createElement("style");
|
|
4461
|
+
return h.id = "rte-modal-styles", h.innerHTML = `
|
|
4447
4462
|
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
4448
4463
|
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
4449
4464
|
[data-radix-popper-content-wrapper] {
|
|
4450
4465
|
z-index: 9999 !important;
|
|
4451
4466
|
}
|
|
4452
|
-
`, document.head.appendChild(
|
|
4453
|
-
const
|
|
4454
|
-
|
|
4467
|
+
`, document.head.appendChild(h), () => {
|
|
4468
|
+
const m = document.getElementById("rte-modal-styles");
|
|
4469
|
+
m && m.remove();
|
|
4455
4470
|
};
|
|
4456
4471
|
}
|
|
4457
4472
|
}, [o]);
|
|
@@ -4476,13 +4491,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4476
4491
|
})
|
|
4477
4492
|
],
|
|
4478
4493
|
content: a || "",
|
|
4479
|
-
onUpdate: ({ editor:
|
|
4480
|
-
const
|
|
4481
|
-
l(
|
|
4494
|
+
onUpdate: ({ editor: h }) => {
|
|
4495
|
+
const m = h.getHTML();
|
|
4496
|
+
l(m);
|
|
4482
4497
|
},
|
|
4483
|
-
onBlur: ({ editor:
|
|
4484
|
-
const
|
|
4485
|
-
i(r,
|
|
4498
|
+
onBlur: ({ editor: h }) => {
|
|
4499
|
+
const m = h.getHTML();
|
|
4500
|
+
i(r, m);
|
|
4486
4501
|
},
|
|
4487
4502
|
editorProps: {
|
|
4488
4503
|
attributes: {
|
|
@@ -4497,22 +4512,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4497
4512
|
}, [o, u]), useEffect(() => {
|
|
4498
4513
|
c.current && u && (c.current.__chaiRTE = u);
|
|
4499
4514
|
}, [u, o]);
|
|
4500
|
-
const g = (
|
|
4515
|
+
const g = (h) => {
|
|
4501
4516
|
if (!u) return;
|
|
4502
|
-
const
|
|
4517
|
+
const m = `{{${h}}}`;
|
|
4503
4518
|
u.commands.focus();
|
|
4504
4519
|
const { from: f, to: x } = u.state.selection;
|
|
4505
4520
|
if (f !== x)
|
|
4506
|
-
u.chain().deleteSelection().insertContent(
|
|
4521
|
+
u.chain().deleteSelection().insertContent(m).run();
|
|
4507
4522
|
else {
|
|
4508
4523
|
const { state: b } = u, v = b.selection.from, B = b.doc.textBetween(Math.max(0, v - 1), v), w = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
|
|
4509
|
-
let E = "";
|
|
4510
|
-
v > 0 && B !== " " && !/[.,!?;:]/.test(B) && (E = " ");
|
|
4511
4524
|
let _ = "";
|
|
4512
|
-
|
|
4525
|
+
v > 0 && B !== " " && !/[.,!?;:]/.test(B) && (_ = " ");
|
|
4526
|
+
let E = "";
|
|
4527
|
+
w && w !== " " && !/[.,!?;:]/.test(w) && (E = " "), u.chain().insertContent(_ + m + E).run();
|
|
4513
4528
|
}
|
|
4514
4529
|
};
|
|
4515
|
-
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (
|
|
4530
|
+
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
4516
4531
|
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
|
|
4517
4532
|
/* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
|
|
4518
4533
|
Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -4567,9 +4582,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4567
4582
|
}, [g]), useEffect(() => {
|
|
4568
4583
|
u(r || "");
|
|
4569
4584
|
}, [r]);
|
|
4570
|
-
const
|
|
4585
|
+
const h = (f) => {
|
|
4571
4586
|
a(f);
|
|
4572
|
-
},
|
|
4587
|
+
}, m = () => {
|
|
4573
4588
|
d(!1), g && g.commands.setContent(p);
|
|
4574
4589
|
};
|
|
4575
4590
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4581,10 +4596,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4581
4596
|
RTEModal,
|
|
4582
4597
|
{
|
|
4583
4598
|
isOpen: c,
|
|
4584
|
-
onClose:
|
|
4599
|
+
onClose: m,
|
|
4585
4600
|
id: o,
|
|
4586
4601
|
value: p,
|
|
4587
|
-
onChange:
|
|
4602
|
+
onChange: h,
|
|
4588
4603
|
onBlur: l
|
|
4589
4604
|
}
|
|
4590
4605
|
)
|
|
@@ -4600,17 +4615,17 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4600
4615
|
}, [a]), useEffect(() => {
|
|
4601
4616
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4602
4617
|
}, [o, u]);
|
|
4603
|
-
const
|
|
4618
|
+
const h = () => {
|
|
4604
4619
|
const x = findIndex(u, { _id: g });
|
|
4605
4620
|
if (x > -1) {
|
|
4606
|
-
const
|
|
4621
|
+
const k = (x + 1) % u.length, b = get(u, [k, "_id"]);
|
|
4607
4622
|
if (!b) return;
|
|
4608
4623
|
n({ ...o, currentSlide: b }), c([b]);
|
|
4609
4624
|
}
|
|
4610
|
-
},
|
|
4625
|
+
}, m = () => {
|
|
4611
4626
|
const x = findIndex(u, { _id: g });
|
|
4612
4627
|
if (x > -1) {
|
|
4613
|
-
const
|
|
4628
|
+
const k = (x - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
|
|
4614
4629
|
if (!b) return;
|
|
4615
4630
|
n({ ...o, currentSlide: b }), c([b]);
|
|
4616
4631
|
}
|
|
@@ -4618,12 +4633,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4618
4633
|
const x = i(
|
|
4619
4634
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4620
4635
|
p == null ? void 0 : p._id
|
|
4621
|
-
),
|
|
4622
|
-
|
|
4636
|
+
), k = x == null ? void 0 : x._id;
|
|
4637
|
+
k && (n({ ...o, currentSlide: k }), c([k]));
|
|
4623
4638
|
};
|
|
4624
4639
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4625
4640
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4626
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4641
|
+
/* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4627
4642
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4628
4643
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4629
4644
|
" ",
|
|
@@ -4632,7 +4647,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4632
4647
|
"/",
|
|
4633
4648
|
u.length
|
|
4634
4649
|
] }) : "-" }),
|
|
4635
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4650
|
+
/* @__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]" }) }),
|
|
4636
4651
|
/* @__PURE__ */ jsxs(
|
|
4637
4652
|
"button",
|
|
4638
4653
|
{
|
|
@@ -4698,8 +4713,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4698
4713
|
className: "text-xs",
|
|
4699
4714
|
pattern: "[0-9]*",
|
|
4700
4715
|
onChange: (x) => {
|
|
4701
|
-
let
|
|
4702
|
-
|
|
4716
|
+
let k = x.target.value;
|
|
4717
|
+
k.length && (k = k.replace("-", "")), n({ ...o, autoplayInterval: k });
|
|
4703
4718
|
}
|
|
4704
4719
|
}
|
|
4705
4720
|
)
|
|
@@ -4710,7 +4725,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4710
4725
|
const r = get(o, "srcsets", []) || [], a = (c, d) => {
|
|
4711
4726
|
const p = c.target.name, u = c.target.value;
|
|
4712
4727
|
n({
|
|
4713
|
-
srcsets: map(r, (g,
|
|
4728
|
+
srcsets: map(r, (g, h) => h === d ? { ...g, [p]: u } : g)
|
|
4714
4729
|
});
|
|
4715
4730
|
}, l = () => {
|
|
4716
4731
|
n({ srcsets: [...r, {}] });
|
|
@@ -4805,30 +4820,30 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4805
4820
|
required: p,
|
|
4806
4821
|
schema: u,
|
|
4807
4822
|
formData: g,
|
|
4808
|
-
onChange:
|
|
4823
|
+
onChange: h
|
|
4809
4824
|
}) => {
|
|
4810
|
-
const { selectedLang:
|
|
4811
|
-
() => isEmpty(x) ? "" : isEmpty(
|
|
4812
|
-
[x,
|
|
4813
|
-
), b = useMemo(() => get(LANGUAGES,
|
|
4825
|
+
const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), k = useMemo(
|
|
4826
|
+
() => isEmpty(x) ? "" : isEmpty(m) ? f : m,
|
|
4827
|
+
[x, m, f]
|
|
4828
|
+
), b = useMemo(() => get(LANGUAGES, k, k), [k]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
|
|
4814
4829
|
() => get(w, [B == null ? void 0 : B._type, "i18nProps"], []),
|
|
4815
4830
|
[w, B == null ? void 0 : B._type]
|
|
4816
|
-
), [
|
|
4831
|
+
), [E, C] = useState(null);
|
|
4817
4832
|
if (d)
|
|
4818
4833
|
return null;
|
|
4819
4834
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
4820
|
-
const N =
|
|
4835
|
+
const N = _ == null ? void 0 : _.includes(o.replace("root.", ""));
|
|
4821
4836
|
if (u.type === "array") {
|
|
4822
|
-
const
|
|
4837
|
+
const S = E === o;
|
|
4823
4838
|
return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
|
|
4824
4839
|
u.title && /* @__PURE__ */ jsxs(
|
|
4825
4840
|
"label",
|
|
4826
4841
|
{
|
|
4827
4842
|
htmlFor: o,
|
|
4828
|
-
onClick: () => S
|
|
4843
|
+
onClick: () => C(S ? null : o),
|
|
4829
4844
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
4830
4845
|
children: [
|
|
4831
|
-
|
|
4846
|
+
S ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
4832
4847
|
/* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
|
|
4833
4848
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
|
|
4834
4849
|
" ",
|
|
@@ -4836,7 +4851,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4836
4851
|
]
|
|
4837
4852
|
}
|
|
4838
4853
|
),
|
|
4839
|
-
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${
|
|
4854
|
+
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${S ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
4840
4855
|
c,
|
|
4841
4856
|
a,
|
|
4842
4857
|
l,
|
|
@@ -4859,8 +4874,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4859
4874
|
DataBindingSelector,
|
|
4860
4875
|
{
|
|
4861
4876
|
schema: u,
|
|
4862
|
-
onChange: (
|
|
4863
|
-
|
|
4877
|
+
onChange: (S) => {
|
|
4878
|
+
h(S, g, o);
|
|
4864
4879
|
},
|
|
4865
4880
|
id: o,
|
|
4866
4881
|
formData: g
|
|
@@ -4907,8 +4922,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4907
4922
|
/* @__PURE__ */ jsx("span", { children: "Add" })
|
|
4908
4923
|
] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
|
|
4909
4924
|
const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
|
|
4910
|
-
async ({ formData: g },
|
|
4911
|
-
l({ formData: g },
|
|
4925
|
+
async ({ formData: g }, h) => {
|
|
4926
|
+
l({ formData: g }, h);
|
|
4912
4927
|
},
|
|
4913
4928
|
[l, i],
|
|
4914
4929
|
400
|
|
@@ -4949,10 +4964,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4949
4964
|
uiSchema: r,
|
|
4950
4965
|
schema: n,
|
|
4951
4966
|
formData: a,
|
|
4952
|
-
onChange: ({ formData: g },
|
|
4953
|
-
if (!
|
|
4954
|
-
const
|
|
4955
|
-
u({ formData: g },
|
|
4967
|
+
onChange: ({ formData: g }, h) => {
|
|
4968
|
+
if (!h || o !== (g == null ? void 0 : g._id)) return;
|
|
4969
|
+
const m = take(h.split("."), 2).join(".").replace("root.", "");
|
|
4970
|
+
u({ formData: g }, m);
|
|
4956
4971
|
}
|
|
4957
4972
|
},
|
|
4958
4973
|
i
|
|
@@ -4964,43 +4979,43 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4964
4979
|
}), a;
|
|
4965
4980
|
};
|
|
4966
4981
|
function BlockSettings() {
|
|
4967
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(),
|
|
4968
|
-
|
|
4982
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: E }, C, A) => {
|
|
4983
|
+
C && (c == null ? void 0 : c._id) === n._id && a([n._id], { [C]: get(E, C) }, A);
|
|
4969
4984
|
}, x = useCallback(
|
|
4970
|
-
debounce(({ formData:
|
|
4971
|
-
f({ formData:
|
|
4985
|
+
debounce(({ formData: E }, C, A) => {
|
|
4986
|
+
f({ formData: E }, C, A), d(E);
|
|
4972
4987
|
}, 1500),
|
|
4973
4988
|
[n == null ? void 0 : n._id, o]
|
|
4974
|
-
),
|
|
4975
|
-
|
|
4976
|
-
}, b = ({ formData:
|
|
4977
|
-
|
|
4989
|
+
), k = ({ formData: E }, C) => {
|
|
4990
|
+
C && (r([n._id], { [C]: get(E, C) }), x({ formData: E }, C, { [C]: get(c, C) }));
|
|
4991
|
+
}, b = ({ formData: E }, C) => {
|
|
4992
|
+
C && (r([g._id], { [C]: get(E, C) }), x({ formData: E }, C, { [C]: get(c, C) }));
|
|
4978
4993
|
}, { schema: v, uiSchema: B } = useMemo(() => {
|
|
4979
|
-
const
|
|
4980
|
-
if (!
|
|
4994
|
+
const E = n == null ? void 0 : n._type;
|
|
4995
|
+
if (!E)
|
|
4981
4996
|
return { schema: {}, uiSchema: {} };
|
|
4982
4997
|
try {
|
|
4983
|
-
const { schema:
|
|
4984
|
-
if (
|
|
4998
|
+
const { schema: C, uiSchema: A } = getBlockFormSchemas(E);
|
|
4999
|
+
if (E === "Repeater") {
|
|
4985
5000
|
const N = get(n, "repeaterItems", "");
|
|
4986
5001
|
startsWith(N, `{{${COLLECTION_PREFIX}`) ? (set(A, "filter", { "ui:widget": "collectionSelect" }), set(A, "sort", { "ui:widget": "collectionSelect" })) : (set(A, "filter", { "ui:widget": "hidden" }), set(A, "sort", { "ui:widget": "hidden" }));
|
|
4987
5002
|
}
|
|
4988
|
-
return { schema:
|
|
5003
|
+
return { schema: C, uiSchema: A };
|
|
4989
5004
|
} catch {
|
|
4990
5005
|
return { schema: {}, uiSchema: {} };
|
|
4991
5006
|
}
|
|
4992
|
-
}, [n]), { wrapperSchema: w, wrapperUiSchema:
|
|
5007
|
+
}, [n]), { wrapperSchema: w, wrapperUiSchema: _ } = useMemo(() => {
|
|
4993
5008
|
if (!g || !(g != null && g._type))
|
|
4994
5009
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
4995
|
-
const
|
|
4996
|
-
return { wrapperSchema:
|
|
5010
|
+
const E = g == null ? void 0 : g._type, { schema: C = {}, uiSchema: A = {} } = getBlockFormSchemas(E);
|
|
5011
|
+
return { wrapperSchema: C, wrapperUiSchema: A };
|
|
4997
5012
|
}, [g]);
|
|
4998
5013
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
4999
5014
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5000
5015
|
/* @__PURE__ */ jsxs(
|
|
5001
5016
|
"div",
|
|
5002
5017
|
{
|
|
5003
|
-
onClick: () => u((
|
|
5018
|
+
onClick: () => u((E) => !E),
|
|
5004
5019
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5005
5020
|
children: [
|
|
5006
5021
|
p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
|
|
@@ -5020,9 +5035,9 @@ function BlockSettings() {
|
|
|
5020
5035
|
{
|
|
5021
5036
|
blockId: g == null ? void 0 : g._id,
|
|
5022
5037
|
onChange: b,
|
|
5023
|
-
formData:
|
|
5038
|
+
formData: m,
|
|
5024
5039
|
schema: w,
|
|
5025
|
-
uiSchema:
|
|
5040
|
+
uiSchema: _
|
|
5026
5041
|
}
|
|
5027
5042
|
) })
|
|
5028
5043
|
] }),
|
|
@@ -5030,7 +5045,7 @@ function BlockSettings() {
|
|
|
5030
5045
|
JSONForm,
|
|
5031
5046
|
{
|
|
5032
5047
|
blockId: n == null ? void 0 : n._id,
|
|
5033
|
-
onChange:
|
|
5048
|
+
onChange: k,
|
|
5034
5049
|
formData: i,
|
|
5035
5050
|
schema: v,
|
|
5036
5051
|
uiSchema: B
|
|
@@ -5210,52 +5225,52 @@ const BlockStylingProps = () => {
|
|
|
5210
5225
|
},
|
|
5211
5226
|
a
|
|
5212
5227
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5213
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [
|
|
5228
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [k, b] = useState(""), [v, B] = useState(!1), [w, _] = useState(!1);
|
|
5214
5229
|
useEffect(() => {
|
|
5215
|
-
const { value:
|
|
5216
|
-
if (
|
|
5217
|
-
l(
|
|
5230
|
+
const { value: S, unit: y } = getClassValueAndUnit(i);
|
|
5231
|
+
if (y === "") {
|
|
5232
|
+
l(S), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5218
5233
|
return;
|
|
5219
5234
|
}
|
|
5220
|
-
|
|
5235
|
+
m(y), l(y === "class" || isEmpty(S) ? "" : S);
|
|
5221
5236
|
}, [i, p, u]);
|
|
5222
|
-
const
|
|
5223
|
-
(
|
|
5224
|
-
const
|
|
5225
|
-
if (get(
|
|
5237
|
+
const E = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), C = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), A = useCallback(
|
|
5238
|
+
(S = !1) => {
|
|
5239
|
+
const y = getUserInputValues(`${a}`, u);
|
|
5240
|
+
if (get(y, "error", !1)) {
|
|
5226
5241
|
x(!0);
|
|
5227
5242
|
return;
|
|
5228
5243
|
}
|
|
5229
|
-
const j = get(
|
|
5244
|
+
const j = get(y, "unit") !== "" ? get(y, "unit") : h;
|
|
5230
5245
|
if (j === "auto" || j === "none") {
|
|
5231
|
-
|
|
5246
|
+
E(`${d}${j}`);
|
|
5232
5247
|
return;
|
|
5233
5248
|
}
|
|
5234
|
-
if (get(
|
|
5249
|
+
if (get(y, "value") === "")
|
|
5235
5250
|
return;
|
|
5236
|
-
const
|
|
5237
|
-
|
|
5251
|
+
const L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5252
|
+
S ? C(L) : E(L);
|
|
5238
5253
|
},
|
|
5239
|
-
[
|
|
5254
|
+
[E, C, a, h, d, u]
|
|
5240
5255
|
), N = useCallback(
|
|
5241
|
-
(
|
|
5242
|
-
const
|
|
5243
|
-
if (get(
|
|
5256
|
+
(S) => {
|
|
5257
|
+
const y = getUserInputValues(`${a}`, u);
|
|
5258
|
+
if (get(y, "error", !1)) {
|
|
5244
5259
|
x(!0);
|
|
5245
5260
|
return;
|
|
5246
5261
|
}
|
|
5247
|
-
if (
|
|
5248
|
-
|
|
5262
|
+
if (S === "auto" || S === "none") {
|
|
5263
|
+
E(`${d}${S}`);
|
|
5249
5264
|
return;
|
|
5250
5265
|
}
|
|
5251
|
-
if (get(
|
|
5266
|
+
if (get(y, "value") === "")
|
|
5252
5267
|
return;
|
|
5253
|
-
const j = get(
|
|
5254
|
-
|
|
5268
|
+
const j = get(y, "unit") !== "" ? get(y, "unit") : S, L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5269
|
+
E(L);
|
|
5255
5270
|
},
|
|
5256
|
-
[
|
|
5271
|
+
[E, a, d, u]
|
|
5257
5272
|
);
|
|
5258
|
-
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children:
|
|
5273
|
+
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: [
|
|
5259
5274
|
/* @__PURE__ */ jsx(
|
|
5260
5275
|
"input",
|
|
5261
5276
|
{
|
|
@@ -5270,35 +5285,35 @@ const BlockStylingProps = () => {
|
|
|
5270
5285
|
] })
|
|
5271
5286
|
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
|
|
5272
5287
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
5273
|
-
["none", "auto"].indexOf(
|
|
5288
|
+
["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
5274
5289
|
"input",
|
|
5275
5290
|
{
|
|
5276
|
-
readOnly:
|
|
5277
|
-
onKeyPress: (
|
|
5278
|
-
|
|
5291
|
+
readOnly: h === "class",
|
|
5292
|
+
onKeyPress: (S) => {
|
|
5293
|
+
S.key === "Enter" && A();
|
|
5279
5294
|
},
|
|
5280
|
-
onKeyDown: (
|
|
5281
|
-
if (
|
|
5295
|
+
onKeyDown: (S) => {
|
|
5296
|
+
if (S.keyCode !== 38 && S.keyCode !== 40)
|
|
5282
5297
|
return;
|
|
5283
|
-
|
|
5284
|
-
const
|
|
5285
|
-
let j = isNaN$1(
|
|
5286
|
-
|
|
5287
|
-
const
|
|
5288
|
-
|
|
5298
|
+
S.preventDefault(), _(!0);
|
|
5299
|
+
const y = parseInt$1(S.target.value);
|
|
5300
|
+
let j = isNaN$1(y) ? 0 : y;
|
|
5301
|
+
S.keyCode === 38 && (j += 1), S.keyCode === 40 && (j -= 1);
|
|
5302
|
+
const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5303
|
+
C(R);
|
|
5289
5304
|
},
|
|
5290
|
-
onKeyUp: (
|
|
5291
|
-
w && (
|
|
5305
|
+
onKeyUp: (S) => {
|
|
5306
|
+
w && (S.preventDefault(), _(!1));
|
|
5292
5307
|
},
|
|
5293
5308
|
onBlur: () => A(),
|
|
5294
|
-
onChange: (
|
|
5295
|
-
x(!1), l(
|
|
5309
|
+
onChange: (S) => {
|
|
5310
|
+
x(!1), l(S.target.value);
|
|
5296
5311
|
},
|
|
5297
|
-
onClick: (
|
|
5298
|
-
var
|
|
5299
|
-
(
|
|
5312
|
+
onClick: (S) => {
|
|
5313
|
+
var y;
|
|
5314
|
+
(y = S == null ? void 0 : S.target) == null || y.select(), r(!1);
|
|
5300
5315
|
},
|
|
5301
|
-
value: v ?
|
|
5316
|
+
value: v ? k : a,
|
|
5302
5317
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
5303
5318
|
" ",
|
|
5304
5319
|
f ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
@@ -5313,7 +5328,7 @@ const BlockStylingProps = () => {
|
|
|
5313
5328
|
onClick: () => r(!n),
|
|
5314
5329
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
5315
5330
|
children: [
|
|
5316
|
-
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children:
|
|
5331
|
+
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: h }),
|
|
5317
5332
|
u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
|
|
5318
5333
|
]
|
|
5319
5334
|
}
|
|
@@ -5322,33 +5337,33 @@ const BlockStylingProps = () => {
|
|
|
5322
5337
|
UnitSelection,
|
|
5323
5338
|
{
|
|
5324
5339
|
units: u,
|
|
5325
|
-
current:
|
|
5326
|
-
onSelect: (
|
|
5327
|
-
r(!1),
|
|
5340
|
+
current: h,
|
|
5341
|
+
onSelect: (S) => {
|
|
5342
|
+
r(!1), m(S), N(S);
|
|
5328
5343
|
}
|
|
5329
5344
|
}
|
|
5330
5345
|
) })
|
|
5331
5346
|
] })
|
|
5332
5347
|
] }),
|
|
5333
|
-
["none", "auto"].indexOf(
|
|
5348
|
+
["none", "auto"].indexOf(h) !== -1 || v ? null : /* @__PURE__ */ jsx(
|
|
5334
5349
|
DragStyleButton,
|
|
5335
5350
|
{
|
|
5336
5351
|
onDragStart: () => B(!0),
|
|
5337
|
-
onDragEnd: (
|
|
5338
|
-
if (b(() => ""), B(!1), isEmpty(
|
|
5352
|
+
onDragEnd: (S) => {
|
|
5353
|
+
if (b(() => ""), B(!1), isEmpty(S))
|
|
5339
5354
|
return;
|
|
5340
|
-
const
|
|
5341
|
-
|
|
5355
|
+
const y = `${S}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5356
|
+
E(I);
|
|
5342
5357
|
},
|
|
5343
|
-
onDrag: (
|
|
5344
|
-
if (isEmpty(
|
|
5358
|
+
onDrag: (S) => {
|
|
5359
|
+
if (isEmpty(S))
|
|
5345
5360
|
return;
|
|
5346
|
-
b(
|
|
5347
|
-
const
|
|
5348
|
-
|
|
5361
|
+
b(S);
|
|
5362
|
+
const y = `${S}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5363
|
+
C(I);
|
|
5349
5364
|
},
|
|
5350
5365
|
currentValue: a,
|
|
5351
|
-
unit:
|
|
5366
|
+
unit: h,
|
|
5352
5367
|
negative: g,
|
|
5353
5368
|
cssProperty: p
|
|
5354
5369
|
}
|
|
@@ -5408,10 +5423,10 @@ const COLOR_PROP = {
|
|
|
5408
5423
|
ringColor: "ring",
|
|
5409
5424
|
ringOffsetColor: "ring-offset"
|
|
5410
5425
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5411
|
-
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""),
|
|
5426
|
+
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
|
|
5412
5427
|
// eslint-disable-next-line no-shadow
|
|
5413
|
-
(
|
|
5414
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
5428
|
+
(k) => {
|
|
5429
|
+
["current", "inherit", "transparent", "black", "white"].includes(k) ? (c([]), p({ color: k })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: k, shade: b.shade ? b.shade : "500" })));
|
|
5415
5430
|
},
|
|
5416
5431
|
[c, p]
|
|
5417
5432
|
);
|
|
@@ -5422,8 +5437,8 @@ const COLOR_PROP = {
|
|
|
5422
5437
|
}, [g]);
|
|
5423
5438
|
const f = useCallback(
|
|
5424
5439
|
// eslint-disable-next-line no-shadow
|
|
5425
|
-
(
|
|
5426
|
-
p({ color: g, shade:
|
|
5440
|
+
(k) => {
|
|
5441
|
+
p({ color: g, shade: k });
|
|
5427
5442
|
},
|
|
5428
5443
|
[g]
|
|
5429
5444
|
);
|
|
@@ -5441,7 +5456,7 @@ const COLOR_PROP = {
|
|
|
5441
5456
|
disabled: !l,
|
|
5442
5457
|
rounded: !0,
|
|
5443
5458
|
selected: g,
|
|
5444
|
-
onChange:
|
|
5459
|
+
onChange: m,
|
|
5445
5460
|
options: [
|
|
5446
5461
|
"current",
|
|
5447
5462
|
"transparent",
|
|
@@ -5474,7 +5489,7 @@ const COLOR_PROP = {
|
|
|
5474
5489
|
]
|
|
5475
5490
|
}
|
|
5476
5491
|
) }),
|
|
5477
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected:
|
|
5492
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: f, options: i }) })
|
|
5478
5493
|
] });
|
|
5479
5494
|
}, EDITOR_ICONS = {
|
|
5480
5495
|
"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" }) }),
|
|
@@ -5808,22 +5823,22 @@ const COLOR_PROP = {
|
|
|
5808
5823
|
"2xl": "1536px"
|
|
5809
5824
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
5810
5825
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
5811
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(),
|
|
5812
|
-
(
|
|
5813
|
-
const N = { dark: p, mq: g, mod: u, cls:
|
|
5826
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), k = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
|
|
5827
|
+
(C, A = !0) => {
|
|
5828
|
+
const N = { dark: p, mq: g, mod: u, cls: C, property: l, fullCls: "" };
|
|
5814
5829
|
(p || u !== "") && (N.mq = "xs");
|
|
5815
|
-
const
|
|
5816
|
-
|
|
5830
|
+
const S = generateFullClsName(N);
|
|
5831
|
+
m(x, [S], A);
|
|
5817
5832
|
},
|
|
5818
|
-
[x, p, g, u, l,
|
|
5833
|
+
[x, p, g, u, l, m]
|
|
5819
5834
|
), v = useCallback(() => {
|
|
5820
|
-
f(x, [
|
|
5821
|
-
}, [x,
|
|
5835
|
+
f(x, [k], !0);
|
|
5836
|
+
}, [x, k, f]), B = useMemo(() => canChangeClass(h, g), [h, g]);
|
|
5822
5837
|
useEffect(() => {
|
|
5823
|
-
i(B,
|
|
5824
|
-
}, [B, i,
|
|
5825
|
-
const [, , w] = useScreenSizeWidth(),
|
|
5826
|
-
(
|
|
5838
|
+
i(B, h);
|
|
5839
|
+
}, [B, i, h]);
|
|
5840
|
+
const [, , w] = useScreenSizeWidth(), _ = useCallback(
|
|
5841
|
+
(C) => {
|
|
5827
5842
|
w({
|
|
5828
5843
|
xs: 400,
|
|
5829
5844
|
sm: 640,
|
|
@@ -5831,18 +5846,18 @@ const COLOR_PROP = {
|
|
|
5831
5846
|
lg: 1024,
|
|
5832
5847
|
xl: 1420,
|
|
5833
5848
|
"2xl": 1920
|
|
5834
|
-
}[
|
|
5849
|
+
}[C]);
|
|
5835
5850
|
},
|
|
5836
5851
|
[w]
|
|
5837
|
-
),
|
|
5838
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset:
|
|
5839
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${
|
|
5852
|
+
), E = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
|
|
5853
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: h && E, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
5854
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !E ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
5840
5855
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
5841
5856
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
5842
5857
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
5843
5858
|
AdvanceChoices,
|
|
5844
5859
|
{
|
|
5845
|
-
currentClass: get(
|
|
5860
|
+
currentClass: get(h, "cls", ""),
|
|
5846
5861
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
5847
5862
|
units: c || [],
|
|
5848
5863
|
onChange: b,
|
|
@@ -5855,7 +5870,7 @@ const COLOR_PROP = {
|
|
|
5855
5870
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
5856
5871
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
5857
5872
|
] }),
|
|
5858
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${
|
|
5873
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${k ? "visible" : "invisible"}`, children: E ? /* @__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" }) }) : B && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
5859
5874
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5860
5875
|
"button",
|
|
5861
5876
|
{
|
|
@@ -5867,19 +5882,19 @@ const COLOR_PROP = {
|
|
|
5867
5882
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
5868
5883
|
"Current style is set at ",
|
|
5869
5884
|
/* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
|
|
5870
|
-
getBreakpoint(get(
|
|
5871
|
-
p && !
|
|
5885
|
+
getBreakpoint(get(h, "mq")),
|
|
5886
|
+
p && !h.dark ? "(Light mode)" : ""
|
|
5872
5887
|
] }),
|
|
5873
5888
|
/* @__PURE__ */ jsx("br", {}),
|
|
5874
5889
|
/* @__PURE__ */ jsxs(
|
|
5875
5890
|
"button",
|
|
5876
5891
|
{
|
|
5877
5892
|
type: "button",
|
|
5878
|
-
onClick: () =>
|
|
5893
|
+
onClick: () => _(get(h, "mq")),
|
|
5879
5894
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
5880
5895
|
children: [
|
|
5881
5896
|
"Switch to ",
|
|
5882
|
-
get(
|
|
5897
|
+
get(h, "mq").toUpperCase()
|
|
5883
5898
|
]
|
|
5884
5899
|
}
|
|
5885
5900
|
)
|
|
@@ -5896,7 +5911,7 @@ const COLOR_PROP = {
|
|
|
5896
5911
|
units: i = basicUnits,
|
|
5897
5912
|
negative: c = !1
|
|
5898
5913
|
}) => {
|
|
5899
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(),
|
|
5914
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), h = useCallback((m) => map(g, "property").includes(m), [g]);
|
|
5900
5915
|
return /* @__PURE__ */ jsxs(
|
|
5901
5916
|
"div",
|
|
5902
5917
|
{
|
|
@@ -5904,7 +5919,7 @@ const COLOR_PROP = {
|
|
|
5904
5919
|
children: [
|
|
5905
5920
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
5906
5921
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
5907
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label:
|
|
5922
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: m, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5908
5923
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
5909
5924
|
"button",
|
|
5910
5925
|
{
|
|
@@ -5913,13 +5928,13 @@ const COLOR_PROP = {
|
|
|
5913
5928
|
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
5914
5929
|
children: [
|
|
5915
5930
|
React__default.createElement("div", {
|
|
5916
|
-
className:
|
|
5931
|
+
className: h(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
5917
5932
|
}),
|
|
5918
5933
|
React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
5919
5934
|
]
|
|
5920
5935
|
}
|
|
5921
5936
|
) }),
|
|
5922
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(
|
|
5937
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
|
|
5923
5938
|
] }) }, `option-${x}`)) })
|
|
5924
5939
|
] }),
|
|
5925
5940
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
@@ -6075,23 +6090,23 @@ const COLOR_PROP = {
|
|
|
6075
6090
|
canvas: n = !1,
|
|
6076
6091
|
tooltip: r = !0
|
|
6077
6092
|
}) => {
|
|
6078
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t:
|
|
6093
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
|
|
6079
6094
|
u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
|
|
6080
6095
|
}, x = (b) => {
|
|
6081
6096
|
n || l(b), c(b);
|
|
6082
|
-
},
|
|
6083
|
-
return
|
|
6097
|
+
}, k = getBreakpointValue(n ? i : a).toLowerCase();
|
|
6098
|
+
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
|
|
6084
6099
|
BreakpointCard,
|
|
6085
6100
|
{
|
|
6086
6101
|
canvas: n,
|
|
6087
6102
|
...b,
|
|
6088
6103
|
onClick: x,
|
|
6089
6104
|
key: b.breakpoint,
|
|
6090
|
-
currentBreakpoint:
|
|
6105
|
+
currentBreakpoint: k
|
|
6091
6106
|
}
|
|
6092
6107
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
6093
6108
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
6094
|
-
|
|
6109
|
+
m.filter((b) => includes(u, toUpper(b.breakpoint))),
|
|
6095
6110
|
(b) => /* @__PURE__ */ createElement(
|
|
6096
6111
|
BreakpointCard,
|
|
6097
6112
|
{
|
|
@@ -6101,22 +6116,22 @@ const COLOR_PROP = {
|
|
|
6101
6116
|
...b,
|
|
6102
6117
|
onClick: x,
|
|
6103
6118
|
key: b.breakpoint,
|
|
6104
|
-
currentBreakpoint:
|
|
6119
|
+
currentBreakpoint: k
|
|
6105
6120
|
}
|
|
6106
6121
|
)
|
|
6107
6122
|
) }),
|
|
6108
6123
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
6109
6124
|
/* @__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" }) }) }),
|
|
6110
6125
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
6111
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { children:
|
|
6126
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: h("Screen sizes") }),
|
|
6112
6127
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
6113
|
-
map(
|
|
6128
|
+
map(m, (b) => /* @__PURE__ */ jsx(
|
|
6114
6129
|
DropdownMenuCheckboxItem,
|
|
6115
6130
|
{
|
|
6116
6131
|
disabled: b.breakpoint === "xs",
|
|
6117
6132
|
onCheckedChange: () => f(toUpper(b.breakpoint)),
|
|
6118
6133
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
6119
|
-
children:
|
|
6134
|
+
children: h(b.title)
|
|
6120
6135
|
},
|
|
6121
6136
|
b.breakpoint
|
|
6122
6137
|
))
|
|
@@ -6195,11 +6210,11 @@ function Countdown() {
|
|
|
6195
6210
|
const AskAIStyles = ({ blockId: o }) => {
|
|
6196
6211
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
|
|
6197
6212
|
useEffect(() => {
|
|
6198
|
-
var
|
|
6199
|
-
(
|
|
6213
|
+
var m;
|
|
6214
|
+
(m = d.current) == null || m.focus();
|
|
6200
6215
|
}, []);
|
|
6201
|
-
const
|
|
6202
|
-
const { usage: f } =
|
|
6216
|
+
const h = (m) => {
|
|
6217
|
+
const { usage: f } = m || {};
|
|
6203
6218
|
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
6204
6219
|
};
|
|
6205
6220
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -6209,12 +6224,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6209
6224
|
{
|
|
6210
6225
|
ref: d,
|
|
6211
6226
|
value: i,
|
|
6212
|
-
onChange: (
|
|
6227
|
+
onChange: (m) => c(m.target.value),
|
|
6213
6228
|
placeholder: n("Ask AI to edit styles"),
|
|
6214
6229
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
6215
6230
|
rows: 4,
|
|
6216
|
-
onKeyDown: (
|
|
6217
|
-
|
|
6231
|
+
onKeyDown: (m) => {
|
|
6232
|
+
m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h));
|
|
6218
6233
|
}
|
|
6219
6234
|
}
|
|
6220
6235
|
),
|
|
@@ -6224,7 +6239,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6224
6239
|
{
|
|
6225
6240
|
disabled: i.trim().length < 5 || a,
|
|
6226
6241
|
onClick: () => {
|
|
6227
|
-
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i,
|
|
6242
|
+
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h);
|
|
6228
6243
|
},
|
|
6229
6244
|
variant: "default",
|
|
6230
6245
|
className: "w-fit",
|
|
@@ -6255,25 +6270,25 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6255
6270
|
] });
|
|
6256
6271
|
};
|
|
6257
6272
|
function ManualClasses() {
|
|
6258
|
-
var
|
|
6259
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [
|
|
6260
|
-
const
|
|
6261
|
-
u(
|
|
6262
|
-
}, [w,
|
|
6263
|
-
const R =
|
|
6273
|
+
var I;
|
|
6274
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), k = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), v = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
|
|
6275
|
+
const L = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6276
|
+
u(h, L, !0), x("");
|
|
6277
|
+
}, [w, _] = useState([]), E = ({ value: L }) => {
|
|
6278
|
+
const R = L.trim().toLowerCase(), T = R.match(/.+:/g);
|
|
6264
6279
|
let D = [];
|
|
6265
|
-
if (
|
|
6266
|
-
const [O] =
|
|
6280
|
+
if (T && T.length > 0) {
|
|
6281
|
+
const [O] = T, P = R.replace(O, "");
|
|
6267
6282
|
D = i.search(P).map((M) => ({
|
|
6268
6283
|
...M,
|
|
6269
6284
|
item: { ...M.item, name: O + M.item.name }
|
|
6270
6285
|
}));
|
|
6271
6286
|
} else
|
|
6272
6287
|
D = i.search(R);
|
|
6273
|
-
return
|
|
6274
|
-
},
|
|
6275
|
-
|
|
6276
|
-
}, A = (
|
|
6288
|
+
return _(map(D, "item"));
|
|
6289
|
+
}, C = () => {
|
|
6290
|
+
_([]);
|
|
6291
|
+
}, A = (L) => L.name, N = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), S = useMemo(
|
|
6277
6292
|
() => ({
|
|
6278
6293
|
ref: o,
|
|
6279
6294
|
autoComplete: "off",
|
|
@@ -6282,22 +6297,22 @@ function ManualClasses() {
|
|
|
6282
6297
|
spellCheck: !1,
|
|
6283
6298
|
placeholder: c("Enter classes separated by space"),
|
|
6284
6299
|
value: f,
|
|
6285
|
-
onFocus: (
|
|
6300
|
+
onFocus: (L) => {
|
|
6286
6301
|
setTimeout(() => {
|
|
6287
|
-
|
|
6302
|
+
L.target && L.target.select();
|
|
6288
6303
|
}, 0);
|
|
6289
6304
|
},
|
|
6290
|
-
onKeyDown: (
|
|
6291
|
-
|
|
6305
|
+
onKeyDown: (L) => {
|
|
6306
|
+
L.key === "Enter" && f.trim() !== "" && B();
|
|
6292
6307
|
},
|
|
6293
|
-
onChange: (
|
|
6308
|
+
onChange: (L, { newValue: R }) => x(R),
|
|
6294
6309
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
6295
6310
|
}),
|
|
6296
6311
|
[f, c, o]
|
|
6297
|
-
),
|
|
6312
|
+
), y = (L) => {
|
|
6298
6313
|
debugger;
|
|
6299
6314
|
const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6300
|
-
g(
|
|
6315
|
+
g(h, [L]), u(h, R, !0), r(""), l(-1);
|
|
6301
6316
|
}, j = () => {
|
|
6302
6317
|
if (navigator.clipboard === void 0) {
|
|
6303
6318
|
toast.error(c("Clipboard not supported"));
|
|
@@ -6314,7 +6329,7 @@ function ManualClasses() {
|
|
|
6314
6329
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
6315
6330
|
] })
|
|
6316
6331
|
] }),
|
|
6317
|
-
|
|
6332
|
+
m ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
6318
6333
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
|
|
6319
6334
|
/* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
|
|
6320
6335
|
/* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
|
|
@@ -6327,11 +6342,11 @@ function ManualClasses() {
|
|
|
6327
6342
|
Autosuggest,
|
|
6328
6343
|
{
|
|
6329
6344
|
suggestions: w,
|
|
6330
|
-
onSuggestionsFetchRequested:
|
|
6331
|
-
onSuggestionsClearRequested:
|
|
6345
|
+
onSuggestionsFetchRequested: E,
|
|
6346
|
+
onSuggestionsClearRequested: C,
|
|
6332
6347
|
getSuggestionValue: A,
|
|
6333
6348
|
renderSuggestion: N,
|
|
6334
|
-
inputProps:
|
|
6349
|
+
inputProps: S,
|
|
6335
6350
|
containerProps: {
|
|
6336
6351
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
6337
6352
|
},
|
|
@@ -6355,47 +6370,47 @@ function ManualClasses() {
|
|
|
6355
6370
|
)
|
|
6356
6371
|
] }),
|
|
6357
6372
|
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: v.map(
|
|
6358
|
-
(
|
|
6373
|
+
(L, R) => a === R ? /* @__PURE__ */ jsx(
|
|
6359
6374
|
"input",
|
|
6360
6375
|
{
|
|
6361
6376
|
ref: o,
|
|
6362
6377
|
value: n,
|
|
6363
|
-
onChange: (
|
|
6378
|
+
onChange: (T) => r(T.target.value),
|
|
6364
6379
|
onBlur: () => {
|
|
6365
|
-
|
|
6380
|
+
y(L);
|
|
6366
6381
|
},
|
|
6367
|
-
onKeyDown: (
|
|
6368
|
-
|
|
6382
|
+
onKeyDown: (T) => {
|
|
6383
|
+
T.key === "Enter" && y(L);
|
|
6369
6384
|
},
|
|
6370
|
-
onFocus: (
|
|
6385
|
+
onFocus: (T) => {
|
|
6371
6386
|
setTimeout(() => {
|
|
6372
|
-
|
|
6387
|
+
T.target.select();
|
|
6373
6388
|
}, 0);
|
|
6374
6389
|
},
|
|
6375
6390
|
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
|
|
6376
6391
|
},
|
|
6377
|
-
|
|
6392
|
+
L
|
|
6378
6393
|
) : /* @__PURE__ */ jsxs(
|
|
6379
6394
|
"button",
|
|
6380
6395
|
{
|
|
6381
6396
|
onDoubleClick: () => {
|
|
6382
|
-
x(
|
|
6397
|
+
x(L), g(h, [L]), setTimeout(() => {
|
|
6383
6398
|
o.current && o.current.focus();
|
|
6384
6399
|
}, 10);
|
|
6385
6400
|
},
|
|
6386
6401
|
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
|
|
6387
6402
|
children: [
|
|
6388
|
-
|
|
6389
|
-
n !==
|
|
6403
|
+
L,
|
|
6404
|
+
n !== L && /* @__PURE__ */ jsx(
|
|
6390
6405
|
Cross2Icon,
|
|
6391
6406
|
{
|
|
6392
|
-
onClick: () => g(
|
|
6407
|
+
onClick: () => g(h, [L], !0),
|
|
6393
6408
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
6394
6409
|
}
|
|
6395
6410
|
)
|
|
6396
6411
|
]
|
|
6397
6412
|
},
|
|
6398
|
-
|
|
6413
|
+
L
|
|
6399
6414
|
)
|
|
6400
6415
|
) })
|
|
6401
6416
|
] });
|
|
@@ -6509,13 +6524,13 @@ function BlockStyling() {
|
|
|
6509
6524
|
cssProperty: ""
|
|
6510
6525
|
}), d = useThrottledCallback(
|
|
6511
6526
|
(u) => {
|
|
6512
|
-
const g = !get(i, "negative", !1),
|
|
6513
|
-
let
|
|
6514
|
-
|
|
6527
|
+
const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
|
|
6528
|
+
let m = parseFloat(i.dragStartValue);
|
|
6529
|
+
m = isNaN(m) ? 0 : m;
|
|
6515
6530
|
let f = MAPPER[i.dragUnit];
|
|
6516
|
-
(startsWith(
|
|
6517
|
-
let
|
|
6518
|
-
g &&
|
|
6531
|
+
(startsWith(h, "scale") || h === "opacity") && (f = 10);
|
|
6532
|
+
let k = (i.dragStartY - u.pageY) / f + m;
|
|
6533
|
+
g && k < 0 && (k = 0), h === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
|
|
6519
6534
|
},
|
|
6520
6535
|
[i],
|
|
6521
6536
|
50
|
|
@@ -6556,10 +6571,10 @@ const CoreBlock = ({
|
|
|
6556
6571
|
parentId: r,
|
|
6557
6572
|
position: a
|
|
6558
6573
|
}) => {
|
|
6559
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight:
|
|
6574
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
|
|
6560
6575
|
if (has(o, "blocks")) {
|
|
6561
|
-
const
|
|
6562
|
-
u(syncBlocksWithDefaults(
|
|
6576
|
+
const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
|
|
6577
|
+
u(syncBlocksWithDefaults(k), r || null, a);
|
|
6563
6578
|
} else
|
|
6564
6579
|
p(o, r || null, a);
|
|
6565
6580
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
@@ -6569,11 +6584,11 @@ const CoreBlock = ({
|
|
|
6569
6584
|
"button",
|
|
6570
6585
|
{
|
|
6571
6586
|
disabled: n,
|
|
6572
|
-
onClick:
|
|
6587
|
+
onClick: m,
|
|
6573
6588
|
type: "button",
|
|
6574
|
-
onDragStart: (
|
|
6575
|
-
|
|
6576
|
-
g([]),
|
|
6589
|
+
onDragStart: (k) => {
|
|
6590
|
+
k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6591
|
+
g([]), h();
|
|
6577
6592
|
}, 200);
|
|
6578
6593
|
},
|
|
6579
6594
|
draggable: f ? "true" : "false",
|
|
@@ -6772,7 +6787,7 @@ const CoreBlock = ({
|
|
|
6772
6787
|
}
|
|
6773
6788
|
}
|
|
6774
6789
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6775
|
-
var
|
|
6790
|
+
var h, m, f, x, k, b, v, B;
|
|
6776
6791
|
if (r.type === "comment") return [];
|
|
6777
6792
|
let a = { _id: generateUUID() };
|
|
6778
6793
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
@@ -6794,7 +6809,7 @@ const CoreBlock = ({
|
|
|
6794
6809
|
...getAttrs(r),
|
|
6795
6810
|
...getStyles(r)
|
|
6796
6811
|
}, r.attributes) {
|
|
6797
|
-
const w = r.attributes.find((
|
|
6812
|
+
const w = r.attributes.find((_) => includes(NAME_ATTRIBUTES, _.key));
|
|
6798
6813
|
w && (a._name = w.value);
|
|
6799
6814
|
}
|
|
6800
6815
|
if (i)
|
|
@@ -6812,30 +6827,30 @@ const CoreBlock = ({
|
|
|
6812
6827
|
];
|
|
6813
6828
|
a = {
|
|
6814
6829
|
...a,
|
|
6815
|
-
href: ((
|
|
6816
|
-
hrefType: ((
|
|
6817
|
-
autoplay: ((f = l.find((
|
|
6818
|
-
maxWidth: ((
|
|
6819
|
-
backdropColor: ((b = l.find((
|
|
6820
|
-
galleryName: ((v = l.find((
|
|
6821
|
-
}, forEach(w, (
|
|
6822
|
-
has(a, `styles_attrs.${
|
|
6830
|
+
href: ((h = l.find((_) => _.key === "href")) == null ? void 0 : h.value) || "",
|
|
6831
|
+
hrefType: ((m = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
|
|
6832
|
+
autoplay: ((f = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
6833
|
+
maxWidth: ((k = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : k.replace("px", "")) || "",
|
|
6834
|
+
backdropColor: ((b = l.find((_) => _.key === "data-overlay")) == null ? void 0 : b.value) || "",
|
|
6835
|
+
galleryName: ((v = l.find((_) => _.key === "data-gall")) == null ? void 0 : v.value) || ""
|
|
6836
|
+
}, forEach(w, (_) => {
|
|
6837
|
+
has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
|
|
6823
6838
|
});
|
|
6824
6839
|
}
|
|
6825
6840
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
6826
6841
|
delete a.styles_attrs;
|
|
6827
|
-
const w = filter(r.children || [], (
|
|
6842
|
+
const w = filter(r.children || [], (E) => (E == null ? void 0 : E.tagName) !== "span");
|
|
6828
6843
|
a.content = getTextContent(w);
|
|
6829
|
-
const
|
|
6844
|
+
const _ = find(
|
|
6830
6845
|
r.children || [],
|
|
6831
|
-
(
|
|
6846
|
+
(E) => (E == null ? void 0 : E.tagName) === "span" && some(E.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg")
|
|
6832
6847
|
);
|
|
6833
|
-
if (
|
|
6834
|
-
const
|
|
6835
|
-
if (
|
|
6836
|
-
a.icon = stringify([
|
|
6837
|
-
const { height:
|
|
6838
|
-
a.iconHeight =
|
|
6848
|
+
if (_) {
|
|
6849
|
+
const E = find(_.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg");
|
|
6850
|
+
if (E) {
|
|
6851
|
+
a.icon = stringify([E]);
|
|
6852
|
+
const { height: C, width: A } = getSvgDimensions(E, "16px", "16px");
|
|
6853
|
+
a.iconHeight = C, a.iconWidth = A;
|
|
6839
6854
|
}
|
|
6840
6855
|
}
|
|
6841
6856
|
return [a];
|
|
@@ -6847,8 +6862,8 @@ const CoreBlock = ({
|
|
|
6847
6862
|
const w = stringify([r]);
|
|
6848
6863
|
return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
|
|
6849
6864
|
} else if (r.tagName === "svg") {
|
|
6850
|
-
const w = find(r.attributes, { key: "height" }),
|
|
6851
|
-
return a.styles = `${STYLES_KEY}, ${cn$2(`w-${
|
|
6865
|
+
const w = find(r.attributes, { key: "height" }), _ = find(r.attributes, { key: "width" }), E = get(w, "value") ? `[${get(w, "value")}px]` : "24px", C = get(_, "value") ? `[${get(_, "value")}px]` : "24px", A = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
6866
|
+
return a.styles = `${STYLES_KEY}, ${cn$2(`w-${C} h-${E}`, A)}`.trim(), r.attributes = filter(r.attributes, (N) => !includes(["style", "width", "height", "class"], N.key)), a.icon = stringify([r]), [a];
|
|
6852
6867
|
} else if (r.tagName == "option" && n && ((B = n.block) == null ? void 0 : B._type) === "Select")
|
|
6853
6868
|
return n.block.options.push({
|
|
6854
6869
|
label: getTextContent(r.children),
|
|
@@ -6956,7 +6971,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
6956
6971
|
parentId: r = void 0,
|
|
6957
6972
|
position: a = -1
|
|
6958
6973
|
}) => {
|
|
6959
|
-
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(),
|
|
6974
|
+
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, 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), k = (B) => {
|
|
6960
6975
|
const w = has(B, "styles_attrs.data-page-section");
|
|
6961
6976
|
return B._type === "Box" && w;
|
|
6962
6977
|
}, b = useCallback(
|
|
@@ -6980,17 +6995,17 @@ const registerChaiLibrary = (o, n) => {
|
|
|
6980
6995
|
draggable: f ? "true" : "false",
|
|
6981
6996
|
onDragStart: async (B) => {
|
|
6982
6997
|
const w = await c({ library: n, block: o });
|
|
6983
|
-
let
|
|
6984
|
-
if (
|
|
6985
|
-
const
|
|
6986
|
-
if (B.dataTransfer.setData("text/plain", JSON.stringify(
|
|
6987
|
-
const
|
|
6988
|
-
|
|
6989
|
-
B.dataTransfer.setDragImage(
|
|
6998
|
+
let _ = r;
|
|
6999
|
+
if (k(first(w)) && (_ = null), !isEmpty(w)) {
|
|
7000
|
+
const E = { blocks: w, uiLibrary: !0, parent: _ };
|
|
7001
|
+
if (B.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
|
|
7002
|
+
const C = new Image();
|
|
7003
|
+
C.src = o.preview, C.onload = () => {
|
|
7004
|
+
B.dataTransfer.setDragImage(C, 0, 0);
|
|
6990
7005
|
};
|
|
6991
7006
|
} else
|
|
6992
7007
|
B.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
6993
|
-
x(
|
|
7008
|
+
x(E), setTimeout(() => {
|
|
6994
7009
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6995
7010
|
}, 200);
|
|
6996
7011
|
}
|
|
@@ -7003,20 +7018,20 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7003
7018
|
/* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
|
|
7004
7019
|
/* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
|
|
7005
7020
|
] }),
|
|
7006
|
-
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt:
|
|
7007
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children:
|
|
7008
|
-
|
|
7021
|
+
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: [
|
|
7022
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: h }),
|
|
7023
|
+
m && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: m })
|
|
7009
7024
|
] })
|
|
7010
7025
|
]
|
|
7011
7026
|
}
|
|
7012
7027
|
) }),
|
|
7013
7028
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
|
|
7014
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium", children:
|
|
7015
|
-
|
|
7029
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: h }),
|
|
7030
|
+
m && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: m })
|
|
7016
7031
|
] }) })
|
|
7017
7032
|
] });
|
|
7018
7033
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7019
|
-
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((
|
|
7034
|
+
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((y) => y.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), f = useRef(null);
|
|
7020
7035
|
useEffect(() => {
|
|
7021
7036
|
c && c.length > 0 && (f.current = new Fuse(c, {
|
|
7022
7037
|
keys: ["name", "label", "description", "group"],
|
|
@@ -7025,28 +7040,28 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7025
7040
|
}));
|
|
7026
7041
|
}, [c]), useEffect(() => {
|
|
7027
7042
|
if (!u.trim() || !f.current) {
|
|
7028
|
-
|
|
7043
|
+
m([]);
|
|
7029
7044
|
return;
|
|
7030
7045
|
}
|
|
7031
|
-
const
|
|
7032
|
-
|
|
7046
|
+
const y = f.current.search(u).map((j) => j.item);
|
|
7047
|
+
m(y);
|
|
7033
7048
|
}, [u]);
|
|
7034
|
-
const x = u.trim() && !isEmpty(
|
|
7049
|
+
const x = u.trim() && !isEmpty(h) ? h : c, k = groupBy(x, "group"), [b, v] = useState(null);
|
|
7035
7050
|
useEffect(() => {
|
|
7036
|
-
if (isEmpty(keys(
|
|
7051
|
+
if (isEmpty(keys(k))) {
|
|
7037
7052
|
v(null);
|
|
7038
7053
|
return;
|
|
7039
7054
|
}
|
|
7040
|
-
if (!b || !
|
|
7041
|
-
v(first(keys(
|
|
7055
|
+
if (!b || !k[b]) {
|
|
7056
|
+
v(first(keys(k)));
|
|
7042
7057
|
return;
|
|
7043
7058
|
}
|
|
7044
|
-
}, [
|
|
7045
|
-
const B = get(
|
|
7059
|
+
}, [k, b]);
|
|
7060
|
+
const B = get(k, b, []), w = useRef(null), { t: _ } = useTranslation(), E = (y) => {
|
|
7046
7061
|
w.current && (clearTimeout(w.current), w.current = null), w.current = setTimeout(() => {
|
|
7047
|
-
w.current && v(
|
|
7062
|
+
w.current && v(y);
|
|
7048
7063
|
}, 400);
|
|
7049
|
-
},
|
|
7064
|
+
}, C = () => {
|
|
7050
7065
|
i != null && i.id && p(i.id);
|
|
7051
7066
|
}, A = () => {
|
|
7052
7067
|
g("");
|
|
@@ -7056,16 +7071,16 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7056
7071
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7057
7072
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7058
7073
|
] });
|
|
7059
|
-
const N = filter(B, (
|
|
7074
|
+
const N = filter(B, (y, j) => j % 2 === 0), S = filter(B, (y, j) => j % 2 === 1);
|
|
7060
7075
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
|
|
7061
7076
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
7062
7077
|
/* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
7063
7078
|
/* @__PURE__ */ jsx(
|
|
7064
7079
|
Input$1,
|
|
7065
7080
|
{
|
|
7066
|
-
placeholder:
|
|
7081
|
+
placeholder: _("Search blocks..."),
|
|
7067
7082
|
value: u,
|
|
7068
|
-
onChange: (
|
|
7083
|
+
onChange: (y) => g(y.target.value),
|
|
7069
7084
|
className: "w-full pl-8 pr-8"
|
|
7070
7085
|
}
|
|
7071
7086
|
),
|
|
@@ -7082,18 +7097,18 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7082
7097
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 min-w-60 max-w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7083
7098
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
|
|
7084
7099
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7085
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7100
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: _("Groups") }),
|
|
7086
7101
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7087
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(
|
|
7088
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm", children:
|
|
7089
|
-
/* @__PURE__ */ jsxs(Button, { onClick:
|
|
7102
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7103
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
|
|
7104
|
+
/* @__PURE__ */ jsxs(Button, { onClick: C, variant: "outline", size: "sm", className: "gap-2", children: [
|
|
7090
7105
|
/* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
|
|
7091
|
-
|
|
7106
|
+
_("Retry")
|
|
7092
7107
|
] })
|
|
7093
|
-
] }) }) : map(
|
|
7108
|
+
] }) }) : map(k, (y, j) => /* @__PURE__ */ jsxs(
|
|
7094
7109
|
"div",
|
|
7095
7110
|
{
|
|
7096
|
-
onMouseEnter: () =>
|
|
7111
|
+
onMouseEnter: () => E(j),
|
|
7097
7112
|
onMouseLeave: () => clearTimeout(w.current),
|
|
7098
7113
|
role: "button",
|
|
7099
7114
|
onClick: () => v(j),
|
|
@@ -7102,7 +7117,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7102
7117
|
j === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
|
|
7103
7118
|
),
|
|
7104
7119
|
children: [
|
|
7105
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(
|
|
7120
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(_(j.toLowerCase())) }),
|
|
7106
7121
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7107
7122
|
]
|
|
7108
7123
|
},
|
|
@@ -7116,23 +7131,23 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7116
7131
|
onMouseEnter: () => w.current ? clearTimeout(w.current) : null,
|
|
7117
7132
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7118
7133
|
children: [
|
|
7119
|
-
isEmpty(B) && !isEmpty(
|
|
7120
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((
|
|
7134
|
+
isEmpty(B) && !isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
|
|
7135
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((y, j) => /* @__PURE__ */ jsx(
|
|
7121
7136
|
BlockCard,
|
|
7122
7137
|
{
|
|
7123
7138
|
parentId: o,
|
|
7124
7139
|
position: n,
|
|
7125
|
-
block:
|
|
7140
|
+
block: y,
|
|
7126
7141
|
library: i
|
|
7127
7142
|
},
|
|
7128
7143
|
`block-${j}`
|
|
7129
7144
|
)) }),
|
|
7130
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7145
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: S.map((y, j) => /* @__PURE__ */ jsx(
|
|
7131
7146
|
BlockCard,
|
|
7132
7147
|
{
|
|
7133
7148
|
parentId: o,
|
|
7134
7149
|
position: n,
|
|
7135
|
-
block:
|
|
7150
|
+
block: y,
|
|
7136
7151
|
library: i
|
|
7137
7152
|
},
|
|
7138
7153
|
`block-second-${j}`
|
|
@@ -7171,8 +7186,8 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7171
7186
|
error: c
|
|
7172
7187
|
}), g(!0);
|
|
7173
7188
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7174
|
-
const
|
|
7175
|
-
const b =
|
|
7189
|
+
const m = Object.entries(a).map(([x, k]) => {
|
|
7190
|
+
const b = k, v = b.type || "partial", B = formatReadableName(v);
|
|
7176
7191
|
return {
|
|
7177
7192
|
type: "PartialBlock",
|
|
7178
7193
|
// Set the type to PartialBlock
|
|
@@ -7186,14 +7201,14 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7186
7201
|
// Store the original ID as partialBlockId
|
|
7187
7202
|
_name: b.name
|
|
7188
7203
|
};
|
|
7189
|
-
}), f = uniq(map(
|
|
7204
|
+
}), f = uniq(map(m, "group"));
|
|
7190
7205
|
p({
|
|
7191
|
-
blocks:
|
|
7206
|
+
blocks: m,
|
|
7192
7207
|
groups: f,
|
|
7193
7208
|
isLoading: !1,
|
|
7194
7209
|
error: null
|
|
7195
7210
|
}), g(!0);
|
|
7196
|
-
} else l ? p((
|
|
7211
|
+
} else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
|
|
7197
7212
|
blocks: [],
|
|
7198
7213
|
groups: [],
|
|
7199
7214
|
isLoading: !1,
|
|
@@ -7208,15 +7223,15 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7208
7223
|
d.blocks,
|
|
7209
7224
|
c
|
|
7210
7225
|
]);
|
|
7211
|
-
const
|
|
7212
|
-
p((
|
|
7226
|
+
const h = () => {
|
|
7227
|
+
p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
|
|
7213
7228
|
};
|
|
7214
7229
|
return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
|
|
7215
7230
|
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
7216
7231
|
/* @__PURE__ */ jsx(
|
|
7217
7232
|
"button",
|
|
7218
7233
|
{
|
|
7219
|
-
onClick:
|
|
7234
|
+
onClick: h,
|
|
7220
7235
|
className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
|
|
7221
7236
|
children: "Refresh"
|
|
7222
7237
|
}
|
|
@@ -7234,44 +7249,44 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7234
7249
|
}, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, n) => {
|
|
7235
7250
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
|
|
7236
7251
|
}, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7237
|
-
var
|
|
7238
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom),
|
|
7252
|
+
var S;
|
|
7253
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (S = find(c, (y) => y._id === r)) == null ? void 0 : S._type, [m, f] = useState("all"), [x, k] = useState(null), b = useRef(null);
|
|
7239
7254
|
useEffect(() => {
|
|
7240
|
-
const
|
|
7255
|
+
const y = setTimeout(() => {
|
|
7241
7256
|
var j;
|
|
7242
7257
|
(j = u.current) == null || j.focus();
|
|
7243
7258
|
}, 0);
|
|
7244
|
-
return () => clearTimeout(
|
|
7259
|
+
return () => clearTimeout(y);
|
|
7245
7260
|
}, [g]), useEffect(() => {
|
|
7246
|
-
d && (f("all"),
|
|
7247
|
-
}, [d]), useEffect(() => (b.current = debounce((
|
|
7248
|
-
f(
|
|
7261
|
+
d && (f("all"), k(null));
|
|
7262
|
+
}, [d]), useEffect(() => (b.current = debounce((y) => {
|
|
7263
|
+
f(y);
|
|
7249
7264
|
}, 500), () => {
|
|
7250
7265
|
b.current && b.current.cancel();
|
|
7251
7266
|
}), []);
|
|
7252
|
-
const v = useCallback((
|
|
7253
|
-
y
|
|
7267
|
+
const v = useCallback((y) => {
|
|
7268
|
+
k(y), b.current && b.current(y);
|
|
7254
7269
|
}, []), B = useCallback(() => {
|
|
7255
|
-
|
|
7256
|
-
}, []), w = useCallback((
|
|
7257
|
-
b.current && b.current.cancel(), f(
|
|
7258
|
-
}, []),
|
|
7270
|
+
k(null), b.current && b.current.cancel();
|
|
7271
|
+
}, []), w = useCallback((y) => {
|
|
7272
|
+
b.current && b.current.cancel(), f(y), k(null);
|
|
7273
|
+
}, []), _ = useMemo(
|
|
7259
7274
|
() => d ? values(n).filter(
|
|
7260
|
-
(
|
|
7261
|
-
var j,
|
|
7262
|
-
return (((j =
|
|
7275
|
+
(y) => {
|
|
7276
|
+
var j, I;
|
|
7277
|
+
return (((j = y.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = y.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
|
|
7263
7278
|
}
|
|
7264
7279
|
) : n,
|
|
7265
7280
|
[n, d]
|
|
7266
|
-
),
|
|
7281
|
+
), E = useMemo(
|
|
7267
7282
|
() => d ? o.filter(
|
|
7268
|
-
(
|
|
7269
|
-
) : o.filter((
|
|
7270
|
-
[n,
|
|
7271
|
-
),
|
|
7272
|
-
() => sortBy(
|
|
7273
|
-
[
|
|
7274
|
-
), A = useMemo(() =>
|
|
7283
|
+
(y) => reject(filter(values(_), { group: y }), { hidden: !0 }).length > 0
|
|
7284
|
+
) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
|
|
7285
|
+
[n, _, o, d]
|
|
7286
|
+
), C = useMemo(
|
|
7287
|
+
() => sortBy(E, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
|
|
7288
|
+
[E]
|
|
7289
|
+
), A = useMemo(() => m === "all" ? _ : filter(values(_), { group: m }), [_, m]), N = useMemo(() => m === "all" ? C : [m], [C, m]);
|
|
7275
7290
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7276
7291
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7277
7292
|
Input$1,
|
|
@@ -7281,43 +7296,43 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7281
7296
|
placeholder: i("Search blocks..."),
|
|
7282
7297
|
value: d,
|
|
7283
7298
|
className: "-ml-2",
|
|
7284
|
-
onChange: (
|
|
7299
|
+
onChange: (y) => p(y.target.value)
|
|
7285
7300
|
}
|
|
7286
7301
|
) }),
|
|
7287
7302
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7288
|
-
|
|
7303
|
+
C.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
7289
7304
|
/* @__PURE__ */ jsx(
|
|
7290
7305
|
"button",
|
|
7291
7306
|
{
|
|
7292
7307
|
onClick: () => w("all"),
|
|
7293
7308
|
onMouseEnter: () => v("all"),
|
|
7294
7309
|
onMouseLeave: B,
|
|
7295
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${
|
|
7310
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7296
7311
|
children: i("All")
|
|
7297
7312
|
},
|
|
7298
7313
|
"sidebar-all"
|
|
7299
7314
|
),
|
|
7300
|
-
|
|
7315
|
+
C.map((y) => /* @__PURE__ */ jsx(
|
|
7301
7316
|
"button",
|
|
7302
7317
|
{
|
|
7303
|
-
onClick: () => w(
|
|
7304
|
-
onMouseEnter: () => v(
|
|
7318
|
+
onClick: () => w(y),
|
|
7319
|
+
onMouseEnter: () => v(y),
|
|
7305
7320
|
onMouseLeave: B,
|
|
7306
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${
|
|
7307
|
-
children: capitalize(i(
|
|
7321
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === y || x === y ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7322
|
+
children: capitalize(i(y.toLowerCase()))
|
|
7308
7323
|
},
|
|
7309
|
-
`sidebar-${
|
|
7324
|
+
`sidebar-${y}`
|
|
7310
7325
|
))
|
|
7311
7326
|
] }) }) }),
|
|
7312
|
-
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children:
|
|
7327
|
+
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: E.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
7313
7328
|
i("No blocks found matching"),
|
|
7314
7329
|
' "',
|
|
7315
7330
|
d,
|
|
7316
7331
|
'"'
|
|
7317
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((
|
|
7318
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7332
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7333
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
|
|
7319
7334
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7320
|
-
|
|
7335
|
+
m === "all" ? filter(values(A), { group: y }) : values(A),
|
|
7321
7336
|
{ hidden: !0 }
|
|
7322
7337
|
).map((j) => /* @__PURE__ */ jsx(
|
|
7323
7338
|
CoreBlock,
|
|
@@ -7325,11 +7340,11 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7325
7340
|
parentId: r,
|
|
7326
7341
|
position: a,
|
|
7327
7342
|
block: j,
|
|
7328
|
-
disabled: !canAcceptChildBlock(
|
|
7343
|
+
disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
|
|
7329
7344
|
},
|
|
7330
7345
|
j.type
|
|
7331
7346
|
)) })
|
|
7332
|
-
] },
|
|
7347
|
+
] }, y)) }) }) })
|
|
7333
7348
|
] })
|
|
7334
7349
|
] });
|
|
7335
7350
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
@@ -7338,13 +7353,13 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7338
7353
|
parentId: r = void 0,
|
|
7339
7354
|
position: a = -1
|
|
7340
7355
|
}) => {
|
|
7341
|
-
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission:
|
|
7356
|
+
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: h } = usePermissions();
|
|
7342
7357
|
useEffect(() => {
|
|
7343
7358
|
i === "partials" && !g && c("library");
|
|
7344
7359
|
}, [i, g, c]);
|
|
7345
|
-
const
|
|
7360
|
+
const m = useCallback(() => {
|
|
7346
7361
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7347
|
-
}, []), f = useChaiAddBlockTabs(), x = p &&
|
|
7362
|
+
}, []), f = useChaiAddBlockTabs(), x = p && h(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
|
|
7348
7363
|
return useEffect(() => {
|
|
7349
7364
|
i === "library" && !b && c("core");
|
|
7350
7365
|
}, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7372,7 +7387,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7372
7387
|
b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7373
7388
|
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: r, position: a }) }) }) }),
|
|
7374
7389
|
x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7375
|
-
map(f, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close:
|
|
7390
|
+
map(f, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: m, parentId: r, position: a }) }, `panel-add-block-${v.id}`))
|
|
7376
7391
|
]
|
|
7377
7392
|
}
|
|
7378
7393
|
)
|
|
@@ -7494,7 +7509,7 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7494
7509
|
}, CANNOT_COPY_BLOCKS = !navigator.clipboard, CopyPasteBlocks = () => {
|
|
7495
7510
|
const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useCallback(() => {
|
|
7496
7511
|
const p = n.map((u) => {
|
|
7497
|
-
const g = o.find((
|
|
7512
|
+
const g = o.find((h) => h._id === u);
|
|
7498
7513
|
return {
|
|
7499
7514
|
id: u,
|
|
7500
7515
|
data: g
|
|
@@ -7679,44 +7694,44 @@ const Input = ({ node: o }) => {
|
|
|
7679
7694
|
var R;
|
|
7680
7695
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
|
|
7681
7696
|
let p = null;
|
|
7682
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight:
|
|
7683
|
-
|
|
7684
|
-
},
|
|
7685
|
-
|
|
7686
|
-
},
|
|
7687
|
-
|
|
7688
|
-
}, [
|
|
7689
|
-
var
|
|
7690
|
-
|
|
7691
|
-
},
|
|
7697
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: k, isDragging: b, isEditing: v, handleClick: B } = o, w = (T) => {
|
|
7698
|
+
T.stopPropagation(), !l.includes(m) && o.toggle();
|
|
7699
|
+
}, _ = (T) => {
|
|
7700
|
+
T.isInternal && (p = T.isOpen, T.isOpen && T.close());
|
|
7701
|
+
}, E = (T) => {
|
|
7702
|
+
T.isInternal && p !== null && (p ? T.open() : T.close(), p = null);
|
|
7703
|
+
}, [C, A] = useAtom$1(currentAddSelection), N = () => {
|
|
7704
|
+
var T;
|
|
7705
|
+
S(), o.parent.isSelected || A((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
|
|
7706
|
+
}, S = () => {
|
|
7692
7707
|
A(null);
|
|
7693
|
-
},
|
|
7694
|
-
|
|
7708
|
+
}, y = (T) => {
|
|
7709
|
+
S(), T.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(T);
|
|
7695
7710
|
};
|
|
7696
7711
|
useEffect(() => {
|
|
7697
|
-
const
|
|
7698
|
-
|
|
7712
|
+
const T = setTimeout(() => {
|
|
7713
|
+
k && !o.isOpen && !b && !l.includes(m) && o.toggle();
|
|
7699
7714
|
}, 500);
|
|
7700
|
-
return () => clearTimeout(
|
|
7701
|
-
}, [
|
|
7702
|
-
const j = (
|
|
7703
|
-
const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${
|
|
7715
|
+
return () => clearTimeout(T);
|
|
7716
|
+
}, [k, o, b]);
|
|
7717
|
+
const j = (T, D) => {
|
|
7718
|
+
const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
|
|
7704
7719
|
P && P.setAttribute("data-drop", D);
|
|
7705
7720
|
const $ = P.getBoundingClientRect(), M = c.getBoundingClientRect();
|
|
7706
7721
|
$.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = P.offsetTop - M.top);
|
|
7707
|
-
},
|
|
7708
|
-
|
|
7722
|
+
}, I = (T) => {
|
|
7723
|
+
S();
|
|
7709
7724
|
const D = get(o, "parent.id");
|
|
7710
|
-
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position:
|
|
7725
|
+
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
|
|
7711
7726
|
};
|
|
7712
|
-
if (
|
|
7727
|
+
if (m === ROOT_TEMP_KEY)
|
|
7713
7728
|
return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7714
7729
|
/* @__PURE__ */ jsx("br", {}),
|
|
7715
7730
|
d(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
|
|
7716
7731
|
"div",
|
|
7717
7732
|
{
|
|
7718
7733
|
role: "button",
|
|
7719
|
-
onClick: () =>
|
|
7734
|
+
onClick: () => I(-1),
|
|
7720
7735
|
className: "h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",
|
|
7721
7736
|
children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-primary px-3 py-1 text-[9px] leading-tight text-white hover:bg-primary", children: [
|
|
7722
7737
|
/* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -7727,36 +7742,36 @@ const Input = ({ node: o }) => {
|
|
|
7727
7742
|
),
|
|
7728
7743
|
/* @__PURE__ */ jsx("br", {})
|
|
7729
7744
|
] });
|
|
7730
|
-
const
|
|
7745
|
+
const L = useMemo(() => has(f, "_libBlockId") && !isEmpty(f._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [f, d]);
|
|
7731
7746
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7732
7747
|
"div",
|
|
7733
7748
|
{
|
|
7734
|
-
onMouseEnter: () => g(
|
|
7735
|
-
onMouseLeave: () =>
|
|
7736
|
-
onClick:
|
|
7749
|
+
onMouseEnter: () => g(m),
|
|
7750
|
+
onMouseLeave: () => h(),
|
|
7751
|
+
onClick: y,
|
|
7737
7752
|
style: n,
|
|
7738
|
-
"data-node-id":
|
|
7739
|
-
ref: l.includes(
|
|
7740
|
-
onDragStart: () =>
|
|
7741
|
-
onDragEnd: () =>
|
|
7742
|
-
onDragOver: (
|
|
7743
|
-
|
|
7753
|
+
"data-node-id": m,
|
|
7754
|
+
ref: l.includes(m) ? null : r,
|
|
7755
|
+
onDragStart: () => _(o),
|
|
7756
|
+
onDragEnd: () => E(o),
|
|
7757
|
+
onDragOver: (T) => {
|
|
7758
|
+
T.preventDefault(), j(m, "yes");
|
|
7744
7759
|
},
|
|
7745
|
-
onDragLeave: (
|
|
7746
|
-
|
|
7760
|
+
onDragLeave: (T) => {
|
|
7761
|
+
T.preventDefault(), j(m, "no");
|
|
7747
7762
|
},
|
|
7748
|
-
onDrop: (
|
|
7749
|
-
|
|
7763
|
+
onDrop: (T) => {
|
|
7764
|
+
T.preventDefault(), j(m, "no");
|
|
7750
7765
|
},
|
|
7751
7766
|
children: [
|
|
7752
7767
|
d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
7753
7768
|
"div",
|
|
7754
7769
|
{
|
|
7755
|
-
onClick: (
|
|
7756
|
-
|
|
7770
|
+
onClick: (T) => {
|
|
7771
|
+
T.stopPropagation(), I(o.childIndex);
|
|
7757
7772
|
},
|
|
7758
7773
|
onMouseEnter: N,
|
|
7759
|
-
onMouseLeave:
|
|
7774
|
+
onMouseLeave: S,
|
|
7760
7775
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
7761
7776
|
children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
|
|
7762
7777
|
}
|
|
@@ -7767,11 +7782,11 @@ const Input = ({ node: o }) => {
|
|
|
7767
7782
|
className: cn(
|
|
7768
7783
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
|
|
7769
7784
|
x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
|
|
7770
|
-
|
|
7771
|
-
(o == null ? void 0 : o.id) ===
|
|
7785
|
+
k && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
|
|
7786
|
+
(o == null ? void 0 : o.id) === C ? "bg-primary/10" : "",
|
|
7772
7787
|
b && "opacity-20",
|
|
7773
|
-
l.includes(
|
|
7774
|
-
|
|
7788
|
+
l.includes(m) ? "opacity-50" : "",
|
|
7789
|
+
L && x && "bg-primary/20 text-primary"
|
|
7775
7790
|
),
|
|
7776
7791
|
children: [
|
|
7777
7792
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7787,8 +7802,8 @@ const Input = ({ node: o }) => {
|
|
|
7787
7802
|
{
|
|
7788
7803
|
className: cn(
|
|
7789
7804
|
"leading-1 flex items-center",
|
|
7790
|
-
|
|
7791
|
-
|
|
7805
|
+
L && "text-primary/60",
|
|
7806
|
+
L && x && "text-primary/80"
|
|
7792
7807
|
),
|
|
7793
7808
|
children: [
|
|
7794
7809
|
/* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
|
|
@@ -7796,8 +7811,8 @@ const Input = ({ node: o }) => {
|
|
|
7796
7811
|
"div",
|
|
7797
7812
|
{
|
|
7798
7813
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
7799
|
-
onDoubleClick: (
|
|
7800
|
-
|
|
7814
|
+
onDoubleClick: (T) => {
|
|
7815
|
+
T.stopPropagation(), o.edit(), o.deselect();
|
|
7801
7816
|
},
|
|
7802
7817
|
children: /* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) })
|
|
7803
7818
|
}
|
|
@@ -7807,11 +7822,11 @@ const Input = ({ node: o }) => {
|
|
|
7807
7822
|
)
|
|
7808
7823
|
] }),
|
|
7809
7824
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7810
|
-
canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(
|
|
7825
|
+
canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7811
7826
|
/* @__PURE__ */ jsx(
|
|
7812
7827
|
TooltipTrigger,
|
|
7813
7828
|
{
|
|
7814
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id:
|
|
7829
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
|
|
7815
7830
|
className: "cursor-pointer rounded bg-transparent",
|
|
7816
7831
|
asChild: !0,
|
|
7817
7832
|
children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3" })
|
|
@@ -7823,8 +7838,8 @@ const Input = ({ node: o }) => {
|
|
|
7823
7838
|
/* @__PURE__ */ jsx(
|
|
7824
7839
|
TooltipTrigger,
|
|
7825
7840
|
{
|
|
7826
|
-
onClick: (
|
|
7827
|
-
|
|
7841
|
+
onClick: (T) => {
|
|
7842
|
+
T.stopPropagation(), i(m), o.isOpen && o.toggle();
|
|
7828
7843
|
},
|
|
7829
7844
|
className: "cursor-pointer rounded bg-transparent",
|
|
7830
7845
|
asChild: !0,
|
|
@@ -7833,7 +7848,7 @@ const Input = ({ node: o }) => {
|
|
|
7833
7848
|
),
|
|
7834
7849
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "bottom", children: a("Hide block") })
|
|
7835
7850
|
] }),
|
|
7836
|
-
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id:
|
|
7851
|
+
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: m, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
|
|
7837
7852
|
] })
|
|
7838
7853
|
]
|
|
7839
7854
|
}
|
|
@@ -8098,9 +8113,9 @@ const Input = ({ node: o }) => {
|
|
|
8098
8113
|
)
|
|
8099
8114
|
] });
|
|
8100
8115
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8101
|
-
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(),
|
|
8116
|
+
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), h = (v) => {
|
|
8102
8117
|
a(v);
|
|
8103
|
-
},
|
|
8118
|
+
}, m = () => {
|
|
8104
8119
|
const v = l.find((B) => Object.keys(B)[0] === r);
|
|
8105
8120
|
if (v) {
|
|
8106
8121
|
const B = Object.values(v)[0];
|
|
@@ -8128,7 +8143,7 @@ const Input = ({ node: o }) => {
|
|
|
8128
8143
|
},
|
|
8129
8144
|
[d],
|
|
8130
8145
|
200
|
|
8131
|
-
),
|
|
8146
|
+
), k = useDebouncedCallback(
|
|
8132
8147
|
(v, B) => {
|
|
8133
8148
|
p(() => {
|
|
8134
8149
|
const w = get(d, `colors.${v}`);
|
|
@@ -8150,10 +8165,10 @@ const Input = ({ node: o }) => {
|
|
|
8150
8165
|
ColorPickerInput,
|
|
8151
8166
|
{
|
|
8152
8167
|
value: w,
|
|
8153
|
-
onChange: (
|
|
8168
|
+
onChange: (_) => k(B, _)
|
|
8154
8169
|
}
|
|
8155
8170
|
),
|
|
8156
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((
|
|
8171
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((_) => _.charAt(0).toUpperCase() + _.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
|
|
8157
8172
|
] }, B);
|
|
8158
8173
|
}) });
|
|
8159
8174
|
return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
@@ -8165,7 +8180,7 @@ const Input = ({ node: o }) => {
|
|
|
8165
8180
|
"select",
|
|
8166
8181
|
{
|
|
8167
8182
|
value: r,
|
|
8168
|
-
onChange: (v) =>
|
|
8183
|
+
onChange: (v) => h(v.target.value),
|
|
8169
8184
|
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",
|
|
8170
8185
|
children: [
|
|
8171
8186
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
@@ -8180,7 +8195,7 @@ const Input = ({ node: o }) => {
|
|
|
8180
8195
|
className: "w-full text-sm",
|
|
8181
8196
|
disabled: r === "",
|
|
8182
8197
|
variant: "default",
|
|
8183
|
-
onClick:
|
|
8198
|
+
onClick: m,
|
|
8184
8199
|
children: g("Apply")
|
|
8185
8200
|
}
|
|
8186
8201
|
) })
|
|
@@ -8674,14 +8689,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8674
8689
|
) }) });
|
|
8675
8690
|
}
|
|
8676
8691
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8677
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(),
|
|
8692
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
|
|
8678
8693
|
useEffect(() => {
|
|
8679
8694
|
var x;
|
|
8680
|
-
(x =
|
|
8695
|
+
(x = h.current) == null || x.focus();
|
|
8681
8696
|
}, []);
|
|
8682
8697
|
const f = (x) => {
|
|
8683
|
-
const { usage:
|
|
8684
|
-
!l &&
|
|
8698
|
+
const { usage: k } = x || {};
|
|
8699
|
+
!l && k && g(k), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8685
8700
|
};
|
|
8686
8701
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8687
8702
|
/* @__PURE__ */ jsxs(
|
|
@@ -8699,14 +8714,14 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8699
8714
|
/* @__PURE__ */ jsx(
|
|
8700
8715
|
Textarea,
|
|
8701
8716
|
{
|
|
8702
|
-
ref:
|
|
8717
|
+
ref: h,
|
|
8703
8718
|
value: i,
|
|
8704
8719
|
onChange: (x) => c(x.target.value),
|
|
8705
8720
|
placeholder: n("Ask AI to edit content"),
|
|
8706
8721
|
className: "w-full",
|
|
8707
8722
|
rows: 3,
|
|
8708
8723
|
onKeyDown: (x) => {
|
|
8709
|
-
x.key === "Enter" && (x.preventDefault(),
|
|
8724
|
+
x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), r("content", o, i, f));
|
|
8710
8725
|
}
|
|
8711
8726
|
}
|
|
8712
8727
|
),
|
|
@@ -8716,7 +8731,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8716
8731
|
{
|
|
8717
8732
|
disabled: i.trim().length < 5 || a,
|
|
8718
8733
|
onClick: () => {
|
|
8719
|
-
|
|
8734
|
+
m.current && clearTimeout(m.current), g(void 0), r("content", o, i, f);
|
|
8720
8735
|
},
|
|
8721
8736
|
variant: "default",
|
|
8722
8737
|
className: "w-fit",
|
|
@@ -8749,7 +8764,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8749
8764
|
QuickPrompts,
|
|
8750
8765
|
{
|
|
8751
8766
|
onClick: (x) => {
|
|
8752
|
-
|
|
8767
|
+
m.current && clearTimeout(m.current), g(void 0), r("content", o, x, f);
|
|
8753
8768
|
}
|
|
8754
8769
|
}
|
|
8755
8770
|
)
|
|
@@ -8759,13 +8774,13 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8759
8774
|
] }) }) : null
|
|
8760
8775
|
] });
|
|
8761
8776
|
}, AISetContext = () => {
|
|
8762
|
-
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1),
|
|
8777
|
+
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), h = useRef(null);
|
|
8763
8778
|
useEffect(() => {
|
|
8764
8779
|
n && a(n);
|
|
8765
8780
|
}, [n]);
|
|
8766
|
-
const
|
|
8781
|
+
const m = async () => {
|
|
8767
8782
|
try {
|
|
8768
|
-
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")),
|
|
8783
|
+
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), h.current.click();
|
|
8769
8784
|
} catch (f) {
|
|
8770
8785
|
u(f);
|
|
8771
8786
|
} finally {
|
|
@@ -8781,7 +8796,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8781
8796
|
type: "single",
|
|
8782
8797
|
collapsible: !0,
|
|
8783
8798
|
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8784
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref:
|
|
8799
|
+
/* @__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") }) }) }),
|
|
8785
8800
|
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
8786
8801
|
/* @__PURE__ */ jsx(
|
|
8787
8802
|
Textarea,
|
|
@@ -8793,7 +8808,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8793
8808
|
className: "mt-1 w-full",
|
|
8794
8809
|
rows: 10,
|
|
8795
8810
|
onKeyDown: (f) => {
|
|
8796
|
-
f.key === "Enter" && (f.preventDefault(),
|
|
8811
|
+
f.key === "Enter" && (f.preventDefault(), m());
|
|
8797
8812
|
}
|
|
8798
8813
|
}
|
|
8799
8814
|
),
|
|
@@ -8805,7 +8820,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8805
8820
|
Button,
|
|
8806
8821
|
{
|
|
8807
8822
|
disabled: r.trim().length < 5,
|
|
8808
|
-
onClick: () =>
|
|
8823
|
+
onClick: () => m(),
|
|
8809
8824
|
variant: "default",
|
|
8810
8825
|
className: "w-fit",
|
|
8811
8826
|
size: "sm",
|
|
@@ -8834,7 +8849,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8834
8849
|
AlertDialogAction,
|
|
8835
8850
|
{
|
|
8836
8851
|
onClick: () => {
|
|
8837
|
-
a(""),
|
|
8852
|
+
a(""), m();
|
|
8838
8853
|
},
|
|
8839
8854
|
children: o("Yes, Delete")
|
|
8840
8855
|
}
|
|
@@ -8895,7 +8910,7 @@ function AIChatPanel() {
|
|
|
8895
8910
|
}, [o]), useEffect(() => {
|
|
8896
8911
|
g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
|
|
8897
8912
|
}, [r]);
|
|
8898
|
-
const
|
|
8913
|
+
const h = async () => {
|
|
8899
8914
|
if (!r.trim() && !c) return;
|
|
8900
8915
|
const b = {
|
|
8901
8916
|
id: Date.now().toString(),
|
|
@@ -8912,22 +8927,22 @@ function AIChatPanel() {
|
|
|
8912
8927
|
};
|
|
8913
8928
|
n((B) => [...B, v]), i(!1), d(null);
|
|
8914
8929
|
}, 1500);
|
|
8915
|
-
},
|
|
8916
|
-
b.key === "Enter" && !b.shiftKey && (b.preventDefault(),
|
|
8930
|
+
}, m = (b) => {
|
|
8931
|
+
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
|
|
8917
8932
|
}, f = (b) => {
|
|
8918
8933
|
var B;
|
|
8919
8934
|
const v = (B = b.target.files) == null ? void 0 : B[0];
|
|
8920
8935
|
if (v) {
|
|
8921
8936
|
const w = new FileReader();
|
|
8922
|
-
w.onload = (
|
|
8923
|
-
var
|
|
8924
|
-
d((
|
|
8937
|
+
w.onload = (_) => {
|
|
8938
|
+
var E;
|
|
8939
|
+
d((E = _.target) == null ? void 0 : E.result);
|
|
8925
8940
|
}, w.readAsDataURL(v);
|
|
8926
8941
|
}
|
|
8927
8942
|
}, x = () => {
|
|
8928
8943
|
var b;
|
|
8929
8944
|
(b = p.current) == null || b.click();
|
|
8930
|
-
},
|
|
8945
|
+
}, k = () => {
|
|
8931
8946
|
d(null), p.current && (p.current.value = "");
|
|
8932
8947
|
};
|
|
8933
8948
|
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
|
|
@@ -8973,7 +8988,7 @@ function AIChatPanel() {
|
|
|
8973
8988
|
size: "icon",
|
|
8974
8989
|
variant: "destructive",
|
|
8975
8990
|
className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
|
|
8976
|
-
onClick:
|
|
8991
|
+
onClick: k,
|
|
8977
8992
|
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
8978
8993
|
}
|
|
8979
8994
|
)
|
|
@@ -8986,7 +9001,7 @@ function AIChatPanel() {
|
|
|
8986
9001
|
ref: g,
|
|
8987
9002
|
value: r,
|
|
8988
9003
|
onChange: (b) => a(b.target.value),
|
|
8989
|
-
onKeyDown:
|
|
9004
|
+
onKeyDown: m,
|
|
8990
9005
|
placeholder: "Ask something...",
|
|
8991
9006
|
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
8992
9007
|
}
|
|
@@ -9008,7 +9023,7 @@ function AIChatPanel() {
|
|
|
9008
9023
|
{
|
|
9009
9024
|
size: "sm",
|
|
9010
9025
|
className: "h-10 px-3",
|
|
9011
|
-
onClick:
|
|
9026
|
+
onClick: h,
|
|
9012
9027
|
disabled: l || !r.trim() && !c,
|
|
9013
9028
|
children: [
|
|
9014
9029
|
/* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
|
|
@@ -9116,53 +9131,53 @@ const AiAssistant = () => {
|
|
|
9116
9131
|
preloadedAttributes: n = [],
|
|
9117
9132
|
onAttributesChange: r
|
|
9118
9133
|
}) {
|
|
9119
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [
|
|
9134
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), k = usePageExternalData();
|
|
9120
9135
|
useEffect(() => {
|
|
9121
9136
|
l(n);
|
|
9122
9137
|
}, [n]);
|
|
9123
9138
|
const b = () => {
|
|
9124
9139
|
if (i.startsWith("@")) {
|
|
9125
|
-
|
|
9140
|
+
m("Attribute keys cannot start with '@'");
|
|
9126
9141
|
return;
|
|
9127
9142
|
}
|
|
9128
9143
|
if (i) {
|
|
9129
|
-
const
|
|
9130
|
-
r(
|
|
9144
|
+
const C = [...a, { key: i, value: d }];
|
|
9145
|
+
r(C), l(a), c(""), p(""), m("");
|
|
9131
9146
|
}
|
|
9132
|
-
}, v = (
|
|
9133
|
-
const A = a.filter((N,
|
|
9147
|
+
}, v = (C) => {
|
|
9148
|
+
const A = a.filter((N, S) => S !== C);
|
|
9134
9149
|
r(A), l(A);
|
|
9135
|
-
}, B = (
|
|
9136
|
-
g(
|
|
9150
|
+
}, B = (C) => {
|
|
9151
|
+
g(C), c(a[C].key), p(a[C].value);
|
|
9137
9152
|
}, w = () => {
|
|
9138
9153
|
if (i.startsWith("@")) {
|
|
9139
|
-
|
|
9154
|
+
m("Attribute keys cannot start with '@'");
|
|
9140
9155
|
return;
|
|
9141
9156
|
}
|
|
9142
9157
|
if (u !== null && i) {
|
|
9143
|
-
const
|
|
9144
|
-
|
|
9158
|
+
const C = [...a];
|
|
9159
|
+
C[u] = { key: i, value: d }, r(C), l(C), g(null), c(""), p(""), m("");
|
|
9145
9160
|
}
|
|
9146
|
-
},
|
|
9147
|
-
|
|
9148
|
-
},
|
|
9149
|
-
const A = (
|
|
9150
|
-
let
|
|
9151
|
-
const
|
|
9152
|
-
return j > 0 && (
|
|
9153
|
-
text:
|
|
9154
|
-
prefixLength:
|
|
9161
|
+
}, _ = (C) => {
|
|
9162
|
+
C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? w() : b());
|
|
9163
|
+
}, E = useCallback((C) => {
|
|
9164
|
+
const A = (y) => /[.,!?;:]/.test(y), N = (y, j, I) => {
|
|
9165
|
+
let L = "", R = "";
|
|
9166
|
+
const T = j > 0 ? y[j - 1] : "", D = j < y.length ? y[j] : "";
|
|
9167
|
+
return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < y.length && !A(D) && D !== " " && (R = " "), {
|
|
9168
|
+
text: L + I + R,
|
|
9169
|
+
prefixLength: L.length,
|
|
9155
9170
|
suffixLength: R.length
|
|
9156
9171
|
};
|
|
9157
|
-
},
|
|
9158
|
-
if (
|
|
9159
|
-
const
|
|
9160
|
-
if (
|
|
9161
|
-
const O = `{{${
|
|
9172
|
+
}, S = x.current;
|
|
9173
|
+
if (S) {
|
|
9174
|
+
const y = S.selectionStart || 0, j = S.value || "", I = S.selectionEnd || y;
|
|
9175
|
+
if (I > y) {
|
|
9176
|
+
const O = `{{${C}}}`, { text: P } = N(j, y, O), $ = j.slice(0, y) + P + j.slice(I);
|
|
9162
9177
|
p($);
|
|
9163
9178
|
return;
|
|
9164
9179
|
}
|
|
9165
|
-
const R = `{{${
|
|
9180
|
+
const R = `{{${C}}}`, { text: T } = N(j, y, R), D = j.slice(0, y) + T + j.slice(y);
|
|
9166
9181
|
p(D);
|
|
9167
9182
|
}
|
|
9168
9183
|
}, []);
|
|
@@ -9170,8 +9185,8 @@ const AiAssistant = () => {
|
|
|
9170
9185
|
/* @__PURE__ */ jsxs(
|
|
9171
9186
|
"form",
|
|
9172
9187
|
{
|
|
9173
|
-
onSubmit: (
|
|
9174
|
-
|
|
9188
|
+
onSubmit: (C) => {
|
|
9189
|
+
C.preventDefault(), u !== null ? w() : b();
|
|
9175
9190
|
},
|
|
9176
9191
|
className: "space-y-3",
|
|
9177
9192
|
children: [
|
|
@@ -9187,7 +9202,7 @@ const AiAssistant = () => {
|
|
|
9187
9202
|
id: "attrKey",
|
|
9188
9203
|
ref: f,
|
|
9189
9204
|
value: i,
|
|
9190
|
-
onChange: (
|
|
9205
|
+
onChange: (C) => c(C.target.value),
|
|
9191
9206
|
placeholder: "Enter Key",
|
|
9192
9207
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9193
9208
|
}
|
|
@@ -9196,7 +9211,7 @@ const AiAssistant = () => {
|
|
|
9196
9211
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9197
9212
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9198
9213
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9199
|
-
!isEmpty(
|
|
9214
|
+
!isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: E })
|
|
9200
9215
|
] }),
|
|
9201
9216
|
/* @__PURE__ */ jsx(
|
|
9202
9217
|
Textarea,
|
|
@@ -9208,8 +9223,8 @@ const AiAssistant = () => {
|
|
|
9208
9223
|
rows: 2,
|
|
9209
9224
|
ref: x,
|
|
9210
9225
|
value: d,
|
|
9211
|
-
onChange: (
|
|
9212
|
-
onKeyDown:
|
|
9226
|
+
onChange: (C) => p(C.target.value),
|
|
9227
|
+
onKeyDown: _,
|
|
9213
9228
|
placeholder: "Enter Value",
|
|
9214
9229
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9215
9230
|
}
|
|
@@ -9217,14 +9232,14 @@ const AiAssistant = () => {
|
|
|
9217
9232
|
] })
|
|
9218
9233
|
] }),
|
|
9219
9234
|
/* @__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" }) }),
|
|
9220
|
-
|
|
9235
|
+
h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
|
|
9221
9236
|
]
|
|
9222
9237
|
}
|
|
9223
9238
|
),
|
|
9224
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
9239
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((C, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9225
9240
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9226
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
9227
|
-
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children:
|
|
9241
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: C.key }),
|
|
9242
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: C.value.toString() })
|
|
9228
9243
|
] }),
|
|
9229
9244
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9230
9245
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
@@ -9348,69 +9363,69 @@ const RootLayout = () => {
|
|
|
9348
9363
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9349
9364
|
r("outline");
|
|
9350
9365
|
});
|
|
9351
|
-
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"),
|
|
9352
|
-
|
|
9353
|
-
}, []),
|
|
9354
|
-
(
|
|
9355
|
-
r(n ===
|
|
9366
|
+
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((C) => {
|
|
9367
|
+
C.preventDefault();
|
|
9368
|
+
}, []), m = useCallback(
|
|
9369
|
+
(C) => {
|
|
9370
|
+
r(n === C ? null : C);
|
|
9356
9371
|
},
|
|
9357
9372
|
[n]
|
|
9358
9373
|
), { t: f } = useTranslation(), x = useMemo(
|
|
9359
9374
|
() => [...p, ...u, ...g],
|
|
9360
9375
|
[p, u, g]
|
|
9361
|
-
),
|
|
9376
|
+
), k = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: n }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
|
|
9362
9377
|
useEffect(() => {
|
|
9363
9378
|
if (n !== null) {
|
|
9364
|
-
const
|
|
9365
|
-
|
|
9379
|
+
const C = find(x, { id: n });
|
|
9380
|
+
C && get(C, "view", "standard") === "standard" && (a.current = n, i(get(C, "width", DEFAULT_PANEL_WIDTH)));
|
|
9366
9381
|
}
|
|
9367
9382
|
}, [n, x]);
|
|
9368
9383
|
const B = useMemo(() => {
|
|
9369
9384
|
if (n === null) return 0;
|
|
9370
|
-
const
|
|
9371
|
-
return get(
|
|
9385
|
+
const C = find(x, { id: n });
|
|
9386
|
+
return get(C, "view", "standard") === "standard" ? v : l;
|
|
9372
9387
|
}, [n, v, l, x]), w = useCallback(() => {
|
|
9373
9388
|
r(a.current);
|
|
9374
|
-
}, [r]),
|
|
9389
|
+
}, [r]), _ = useCallback(() => {
|
|
9375
9390
|
r("outline");
|
|
9376
9391
|
}, [r]);
|
|
9377
9392
|
useEffect(() => {
|
|
9378
9393
|
find(x, { id: n }) || r("outline");
|
|
9379
9394
|
}, [n, x]);
|
|
9380
|
-
const
|
|
9381
|
-
(
|
|
9382
|
-
|
|
9395
|
+
const E = useCallback(
|
|
9396
|
+
(C) => {
|
|
9397
|
+
m(C);
|
|
9383
9398
|
},
|
|
9384
|
-
[
|
|
9399
|
+
[m]
|
|
9385
9400
|
);
|
|
9386
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
9401
|
+
return /* @__PURE__ */ jsx("div", { dir: k, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9387
9402
|
/* @__PURE__ */ jsxs(
|
|
9388
9403
|
"div",
|
|
9389
9404
|
{
|
|
9390
|
-
onContextMenu:
|
|
9405
|
+
onContextMenu: h,
|
|
9391
9406
|
className: "flex h-screen max-h-full flex-col bg-background text-foreground",
|
|
9392
9407
|
children: [
|
|
9393
9408
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9394
9409
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9395
9410
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9396
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((
|
|
9397
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9411
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((C, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9412
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
|
|
9398
9413
|
position: "top",
|
|
9399
|
-
panelId:
|
|
9400
|
-
isActive: n ===
|
|
9401
|
-
show: () =>
|
|
9414
|
+
panelId: C.id,
|
|
9415
|
+
isActive: n === C.id,
|
|
9416
|
+
show: () => E(C.id)
|
|
9402
9417
|
}) }),
|
|
9403
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(
|
|
9418
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(C.label) }) })
|
|
9404
9419
|
] }, "button-top-" + A)) }),
|
|
9405
9420
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9406
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((
|
|
9407
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9421
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((C, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9422
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
|
|
9408
9423
|
position: "bottom",
|
|
9409
|
-
panelId:
|
|
9410
|
-
isActive: n ===
|
|
9411
|
-
show: () =>
|
|
9424
|
+
panelId: C.id,
|
|
9425
|
+
isActive: n === C.id,
|
|
9426
|
+
show: () => E(C.id)
|
|
9412
9427
|
}) }),
|
|
9413
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(
|
|
9428
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(C.label) }) })
|
|
9414
9429
|
] }, "button-bottom-" + A)) })
|
|
9415
9430
|
] }),
|
|
9416
9431
|
/* @__PURE__ */ jsx(
|
|
@@ -9487,7 +9502,7 @@ const RootLayout = () => {
|
|
|
9487
9502
|
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
9488
9503
|
] }) }),
|
|
9489
9504
|
/* @__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), {
|
|
9490
|
-
close:
|
|
9505
|
+
close: _
|
|
9491
9506
|
}) }) })
|
|
9492
9507
|
]
|
|
9493
9508
|
}
|
|
@@ -9499,7 +9514,7 @@ const RootLayout = () => {
|
|
|
9499
9514
|
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
9500
9515
|
] }) }),
|
|
9501
9516
|
/* @__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), {
|
|
9502
|
-
close:
|
|
9517
|
+
close: _
|
|
9503
9518
|
}) }) })
|
|
9504
9519
|
] }) }),
|
|
9505
9520
|
n !== null && get(b, "view") === "overlay" && /* @__PURE__ */ jsx(
|
|
@@ -9527,7 +9542,7 @@ const RootLayout = () => {
|
|
|
9527
9542
|
/* @__PURE__ */ jsx(Button, { onClick: () => w(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
|
|
9528
9543
|
] }),
|
|
9529
9544
|
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
|
|
9530
|
-
close:
|
|
9545
|
+
close: _
|
|
9531
9546
|
}) }) })
|
|
9532
9547
|
]
|
|
9533
9548
|
}
|
|
@@ -9641,226 +9656,226 @@ const FEATURE_TOGGLES = {
|
|
|
9641
9656
|
for (const i of n.p)
|
|
9642
9657
|
l.add(i);
|
|
9643
9658
|
return l;
|
|
9644
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (
|
|
9659
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...f) => m.read(...f), p = (m, ...f) => m.write(...f), u = (m, f) => {
|
|
9645
9660
|
var x;
|
|
9646
|
-
return (x =
|
|
9647
|
-
}, g = (
|
|
9661
|
+
return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
|
|
9662
|
+
}, g = (m, f) => {
|
|
9648
9663
|
var x;
|
|
9649
|
-
return (x =
|
|
9650
|
-
}, ...
|
|
9651
|
-
const
|
|
9664
|
+
return (x = m.onMount) == null ? void 0 : x.call(m, f);
|
|
9665
|
+
}, ...h) => {
|
|
9666
|
+
const m = h[0] || ((A) => {
|
|
9652
9667
|
let N = o.get(A);
|
|
9653
|
-
return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A,
|
|
9654
|
-
}), f =
|
|
9668
|
+
return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, C)), N;
|
|
9669
|
+
}), f = h[1] || (() => {
|
|
9655
9670
|
let A, N;
|
|
9656
|
-
const
|
|
9671
|
+
const S = (y) => {
|
|
9657
9672
|
try {
|
|
9658
|
-
|
|
9673
|
+
y();
|
|
9659
9674
|
} catch (j) {
|
|
9660
9675
|
A || (A = !0, N = j);
|
|
9661
9676
|
}
|
|
9662
9677
|
};
|
|
9663
9678
|
do {
|
|
9664
|
-
c.f &&
|
|
9665
|
-
const
|
|
9666
|
-
a.forEach((
|
|
9667
|
-
var
|
|
9668
|
-
return (
|
|
9669
|
-
}), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(),
|
|
9679
|
+
c.f && S(c.f);
|
|
9680
|
+
const y = /* @__PURE__ */ new Set(), j = y.add.bind(y);
|
|
9681
|
+
a.forEach((I) => {
|
|
9682
|
+
var L;
|
|
9683
|
+
return (L = n.get(I)) == null ? void 0 : L.l.forEach(j);
|
|
9684
|
+
}), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), y.forEach(S), a.size && x();
|
|
9670
9685
|
} while (a.size || i.size || l.size);
|
|
9671
9686
|
if (A)
|
|
9672
9687
|
throw N;
|
|
9673
|
-
}), x =
|
|
9674
|
-
const A = [], N = /* @__PURE__ */ new WeakSet(),
|
|
9675
|
-
for (;
|
|
9676
|
-
const j =
|
|
9677
|
-
if (
|
|
9678
|
-
|
|
9688
|
+
}), x = h[2] || (() => {
|
|
9689
|
+
const A = [], N = /* @__PURE__ */ new WeakSet(), S = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
|
|
9690
|
+
for (; y.length; ) {
|
|
9691
|
+
const j = y[y.length - 1], I = m(j);
|
|
9692
|
+
if (S.has(j)) {
|
|
9693
|
+
y.pop();
|
|
9679
9694
|
continue;
|
|
9680
9695
|
}
|
|
9681
9696
|
if (N.has(j)) {
|
|
9682
|
-
r.get(j) ===
|
|
9697
|
+
r.get(j) === I.n && A.push([j, I]), S.add(j), y.pop();
|
|
9683
9698
|
continue;
|
|
9684
9699
|
}
|
|
9685
9700
|
N.add(j);
|
|
9686
|
-
for (const
|
|
9687
|
-
N.has(
|
|
9701
|
+
for (const L of getMountedOrPendingDependents(j, I, n))
|
|
9702
|
+
N.has(L) || y.push(L);
|
|
9688
9703
|
}
|
|
9689
9704
|
for (let j = A.length - 1; j >= 0; --j) {
|
|
9690
|
-
const [
|
|
9705
|
+
const [I, L] = A[j];
|
|
9691
9706
|
let R = !1;
|
|
9692
|
-
for (const
|
|
9693
|
-
if (
|
|
9707
|
+
for (const T of L.d.keys())
|
|
9708
|
+
if (T !== I && a.has(T)) {
|
|
9694
9709
|
R = !0;
|
|
9695
9710
|
break;
|
|
9696
9711
|
}
|
|
9697
|
-
R && (
|
|
9712
|
+
R && (k(I), B(I)), r.delete(I);
|
|
9698
9713
|
}
|
|
9699
|
-
}),
|
|
9700
|
-
var N,
|
|
9701
|
-
const
|
|
9702
|
-
if (isAtomStateInitialized(
|
|
9714
|
+
}), k = h[3] || ((A) => {
|
|
9715
|
+
var N, S;
|
|
9716
|
+
const y = m(A);
|
|
9717
|
+
if (isAtomStateInitialized(y) && (n.has(A) && r.get(A) !== y.n || Array.from(y.d).every(
|
|
9703
9718
|
([P, $]) => (
|
|
9704
9719
|
// Recursively, read the atom state of the dependency, and
|
|
9705
9720
|
// check if the atom epoch number is unchanged
|
|
9706
|
-
|
|
9721
|
+
k(P).n === $
|
|
9707
9722
|
)
|
|
9708
9723
|
)))
|
|
9709
|
-
return
|
|
9710
|
-
|
|
9724
|
+
return y;
|
|
9725
|
+
y.d.clear();
|
|
9711
9726
|
let j = !0;
|
|
9712
|
-
const
|
|
9727
|
+
const I = () => {
|
|
9713
9728
|
n.has(A) && (B(A), x(), f());
|
|
9714
|
-
},
|
|
9729
|
+
}, L = (P) => {
|
|
9715
9730
|
var $;
|
|
9716
9731
|
if (isSelfAtom(A, P)) {
|
|
9717
|
-
const U =
|
|
9732
|
+
const U = m(P);
|
|
9718
9733
|
if (!isAtomStateInitialized(U))
|
|
9719
9734
|
if (hasInitialValue(P))
|
|
9720
|
-
setAtomStateValueOrPromise(P, P.init,
|
|
9735
|
+
setAtomStateValueOrPromise(P, P.init, m);
|
|
9721
9736
|
else
|
|
9722
9737
|
throw new Error("no atom init");
|
|
9723
9738
|
return returnAtomValue(U);
|
|
9724
9739
|
}
|
|
9725
|
-
const M =
|
|
9740
|
+
const M = k(P);
|
|
9726
9741
|
try {
|
|
9727
9742
|
return returnAtomValue(M);
|
|
9728
9743
|
} finally {
|
|
9729
|
-
|
|
9744
|
+
y.d.set(P, M.n), isPendingPromise(y.v) && addPendingPromiseToDependency(A, y.v, M), ($ = n.get(P)) == null || $.t.add(A), j || I();
|
|
9730
9745
|
}
|
|
9731
9746
|
};
|
|
9732
|
-
let R,
|
|
9747
|
+
let R, T;
|
|
9733
9748
|
const D = {
|
|
9734
9749
|
get signal() {
|
|
9735
9750
|
return R || (R = new AbortController()), R.signal;
|
|
9736
9751
|
},
|
|
9737
9752
|
get setSelf() {
|
|
9738
|
-
return !
|
|
9753
|
+
return !T && isActuallyWritableAtom(A) && (T = (...P) => {
|
|
9739
9754
|
if (!j)
|
|
9740
9755
|
try {
|
|
9741
9756
|
return v(A, ...P);
|
|
9742
9757
|
} finally {
|
|
9743
9758
|
x(), f();
|
|
9744
9759
|
}
|
|
9745
|
-
}),
|
|
9760
|
+
}), T;
|
|
9746
9761
|
}
|
|
9747
|
-
}, O =
|
|
9762
|
+
}, O = y.n;
|
|
9748
9763
|
try {
|
|
9749
|
-
const P = d(A,
|
|
9750
|
-
return setAtomStateValueOrPromise(A, P,
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
)),
|
|
9764
|
+
const P = d(A, L, D);
|
|
9765
|
+
return setAtomStateValueOrPromise(A, P, m), isPromiseLike$1(P) && ((N = P.onCancel) == null || N.call(P, () => R == null ? void 0 : R.abort()), P.then(
|
|
9766
|
+
I,
|
|
9767
|
+
I
|
|
9768
|
+
)), y;
|
|
9754
9769
|
} catch (P) {
|
|
9755
|
-
return delete
|
|
9770
|
+
return delete y.v, y.e = P, ++y.n, y;
|
|
9756
9771
|
} finally {
|
|
9757
|
-
j = !1, O !==
|
|
9772
|
+
j = !1, O !== y.n && r.get(A) === O && (r.set(A, y.n), a.add(A), (S = c.c) == null || S.call(c, A));
|
|
9758
9773
|
}
|
|
9759
|
-
}), b =
|
|
9774
|
+
}), b = h[4] || ((A) => {
|
|
9760
9775
|
const N = [A];
|
|
9761
9776
|
for (; N.length; ) {
|
|
9762
|
-
const
|
|
9763
|
-
for (const j of getMountedOrPendingDependents(
|
|
9764
|
-
const
|
|
9765
|
-
r.set(j,
|
|
9777
|
+
const S = N.pop(), y = m(S);
|
|
9778
|
+
for (const j of getMountedOrPendingDependents(S, y, n)) {
|
|
9779
|
+
const I = m(j);
|
|
9780
|
+
r.set(j, I.n), N.push(j);
|
|
9766
9781
|
}
|
|
9767
9782
|
}
|
|
9768
|
-
}), v =
|
|
9769
|
-
let
|
|
9770
|
-
const
|
|
9783
|
+
}), v = h[5] || ((A, ...N) => {
|
|
9784
|
+
let S = !0;
|
|
9785
|
+
const y = (I) => returnAtomValue(k(I)), j = (I, ...L) => {
|
|
9771
9786
|
var R;
|
|
9772
|
-
const
|
|
9787
|
+
const T = m(I);
|
|
9773
9788
|
try {
|
|
9774
|
-
if (isSelfAtom(A,
|
|
9775
|
-
if (!hasInitialValue(
|
|
9789
|
+
if (isSelfAtom(A, I)) {
|
|
9790
|
+
if (!hasInitialValue(I))
|
|
9776
9791
|
throw new Error("atom not writable");
|
|
9777
|
-
const D =
|
|
9778
|
-
setAtomStateValueOrPromise(
|
|
9792
|
+
const D = T.n, O = L[0];
|
|
9793
|
+
setAtomStateValueOrPromise(I, O, m), B(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
|
|
9779
9794
|
return;
|
|
9780
9795
|
} else
|
|
9781
|
-
return v(
|
|
9796
|
+
return v(I, ...L);
|
|
9782
9797
|
} finally {
|
|
9783
|
-
|
|
9798
|
+
S || (x(), f());
|
|
9784
9799
|
}
|
|
9785
9800
|
};
|
|
9786
9801
|
try {
|
|
9787
|
-
return p(A,
|
|
9802
|
+
return p(A, y, j, ...N);
|
|
9788
9803
|
} finally {
|
|
9789
|
-
|
|
9804
|
+
S = !1;
|
|
9790
9805
|
}
|
|
9791
|
-
}), B =
|
|
9806
|
+
}), B = h[6] || ((A) => {
|
|
9792
9807
|
var N;
|
|
9793
|
-
const
|
|
9794
|
-
if (
|
|
9795
|
-
for (const [j,
|
|
9796
|
-
if (!
|
|
9797
|
-
const
|
|
9798
|
-
w(j).t.add(A),
|
|
9808
|
+
const S = m(A), y = n.get(A);
|
|
9809
|
+
if (y && !isPendingPromise(S.v)) {
|
|
9810
|
+
for (const [j, I] of S.d)
|
|
9811
|
+
if (!y.d.has(j)) {
|
|
9812
|
+
const L = m(j);
|
|
9813
|
+
w(j).t.add(A), y.d.add(j), I !== L.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
|
|
9799
9814
|
}
|
|
9800
|
-
for (const j of
|
|
9801
|
-
if (!
|
|
9802
|
-
|
|
9803
|
-
const
|
|
9804
|
-
|
|
9815
|
+
for (const j of y.d || [])
|
|
9816
|
+
if (!S.d.has(j)) {
|
|
9817
|
+
y.d.delete(j);
|
|
9818
|
+
const I = _(j);
|
|
9819
|
+
I == null || I.t.delete(A);
|
|
9805
9820
|
}
|
|
9806
9821
|
}
|
|
9807
|
-
}), w =
|
|
9822
|
+
}), w = h[7] || ((A) => {
|
|
9808
9823
|
var N;
|
|
9809
|
-
const
|
|
9810
|
-
let
|
|
9811
|
-
if (!
|
|
9812
|
-
|
|
9813
|
-
for (const j of
|
|
9824
|
+
const S = m(A);
|
|
9825
|
+
let y = n.get(A);
|
|
9826
|
+
if (!y) {
|
|
9827
|
+
k(A);
|
|
9828
|
+
for (const j of S.d.keys())
|
|
9814
9829
|
w(j).t.add(A);
|
|
9815
|
-
if (
|
|
9830
|
+
if (y = {
|
|
9816
9831
|
l: /* @__PURE__ */ new Set(),
|
|
9817
|
-
d: new Set(
|
|
9832
|
+
d: new Set(S.d.keys()),
|
|
9818
9833
|
t: /* @__PURE__ */ new Set()
|
|
9819
|
-
}, n.set(A,
|
|
9834
|
+
}, n.set(A, y), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
|
|
9820
9835
|
const j = () => {
|
|
9821
|
-
let
|
|
9822
|
-
const
|
|
9836
|
+
let I = !0;
|
|
9837
|
+
const L = (...R) => {
|
|
9823
9838
|
try {
|
|
9824
9839
|
return v(A, ...R);
|
|
9825
9840
|
} finally {
|
|
9826
|
-
|
|
9841
|
+
I || (x(), f());
|
|
9827
9842
|
}
|
|
9828
9843
|
};
|
|
9829
9844
|
try {
|
|
9830
|
-
const R = g(A,
|
|
9831
|
-
R && (
|
|
9832
|
-
|
|
9845
|
+
const R = g(A, L);
|
|
9846
|
+
R && (y.u = () => {
|
|
9847
|
+
I = !0;
|
|
9833
9848
|
try {
|
|
9834
9849
|
R();
|
|
9835
9850
|
} finally {
|
|
9836
|
-
|
|
9851
|
+
I = !1;
|
|
9837
9852
|
}
|
|
9838
9853
|
});
|
|
9839
9854
|
} finally {
|
|
9840
|
-
|
|
9855
|
+
I = !1;
|
|
9841
9856
|
}
|
|
9842
9857
|
};
|
|
9843
9858
|
l.add(j);
|
|
9844
9859
|
}
|
|
9845
9860
|
}
|
|
9846
|
-
return
|
|
9847
|
-
}),
|
|
9861
|
+
return y;
|
|
9862
|
+
}), _ = h[8] || ((A) => {
|
|
9848
9863
|
var N;
|
|
9849
|
-
const
|
|
9850
|
-
let
|
|
9851
|
-
if (
|
|
9852
|
-
var
|
|
9853
|
-
return (
|
|
9864
|
+
const S = m(A);
|
|
9865
|
+
let y = n.get(A);
|
|
9866
|
+
if (y && !y.l.size && !Array.from(y.t).some((j) => {
|
|
9867
|
+
var I;
|
|
9868
|
+
return (I = n.get(j)) == null ? void 0 : I.d.has(A);
|
|
9854
9869
|
})) {
|
|
9855
|
-
|
|
9856
|
-
for (const j of
|
|
9857
|
-
const
|
|
9858
|
-
|
|
9870
|
+
y.u && i.add(y.u), y = void 0, n.delete(A), (N = c.u) == null || N.call(c, A);
|
|
9871
|
+
for (const j of S.d.keys()) {
|
|
9872
|
+
const I = _(j);
|
|
9873
|
+
I == null || I.t.delete(A);
|
|
9859
9874
|
}
|
|
9860
9875
|
return;
|
|
9861
9876
|
}
|
|
9862
|
-
return
|
|
9863
|
-
}),
|
|
9877
|
+
return y;
|
|
9878
|
+
}), E = [
|
|
9864
9879
|
// store state
|
|
9865
9880
|
o,
|
|
9866
9881
|
n,
|
|
@@ -9875,17 +9890,17 @@ const FEATURE_TOGGLES = {
|
|
|
9875
9890
|
u,
|
|
9876
9891
|
g,
|
|
9877
9892
|
// building-block functions
|
|
9878
|
-
|
|
9893
|
+
m,
|
|
9879
9894
|
f,
|
|
9880
9895
|
x,
|
|
9881
|
-
|
|
9896
|
+
k,
|
|
9882
9897
|
b,
|
|
9883
9898
|
v,
|
|
9884
9899
|
B,
|
|
9885
9900
|
w,
|
|
9886
|
-
|
|
9887
|
-
],
|
|
9888
|
-
get: (A) => returnAtomValue(
|
|
9901
|
+
_
|
|
9902
|
+
], C = {
|
|
9903
|
+
get: (A) => returnAtomValue(k(A)),
|
|
9889
9904
|
set: (A, ...N) => {
|
|
9890
9905
|
try {
|
|
9891
9906
|
return v(A, ...N);
|
|
@@ -9894,13 +9909,13 @@ const FEATURE_TOGGLES = {
|
|
|
9894
9909
|
}
|
|
9895
9910
|
},
|
|
9896
9911
|
sub: (A, N) => {
|
|
9897
|
-
const
|
|
9898
|
-
return
|
|
9899
|
-
|
|
9912
|
+
const y = w(A).l;
|
|
9913
|
+
return y.add(N), f(), () => {
|
|
9914
|
+
y.delete(N), _(A), f();
|
|
9900
9915
|
};
|
|
9901
9916
|
}
|
|
9902
9917
|
};
|
|
9903
|
-
return Object.defineProperty(
|
|
9918
|
+
return Object.defineProperty(C, BUILDING_BLOCKS, { value: E }), C;
|
|
9904
9919
|
}, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
|
|
9905
9920
|
let defaultStore;
|
|
9906
9921
|
const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
|
|
@@ -10075,6 +10090,7 @@ export {
|
|
|
10075
10090
|
useDuplicateBlocks,
|
|
10076
10091
|
useHiddenBlockIds,
|
|
10077
10092
|
useHighlightBlockId,
|
|
10093
|
+
useInlineEditing,
|
|
10078
10094
|
useLanguages,
|
|
10079
10095
|
useLibraryBlocks,
|
|
10080
10096
|
useMediaManagerComponent,
|