camox 0.45.0 → 0.47.0
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/hooks/useArtifactHost.js +2 -2
- package/dist/features/canvas/CamoxCanvas.js +438 -771
- package/dist/features/canvas/CanvasPageFrame.js +1 -3
- package/dist/features/canvas/CanvasPreviewPageSlot.js +26 -6
- package/dist/features/canvas/canvasCamera.js +24 -9
- package/dist/features/canvas/canvasFrameDocument.js +4 -19
- package/dist/features/canvas/canvasItems.js +12 -102
- package/dist/features/canvas/canvasStore.js +3 -92
- package/dist/features/canvas/sidebar/CanvasNavigator.js +81 -183
- package/dist/features/canvas/sidebar/CanvasSidebar.js +22 -28
- package/dist/features/canvas/sidebar/CuratedPageInspector.js +2 -2
- package/dist/features/canvas/useCanvasCamera.js +16 -31
- package/dist/features/canvas/useCanvasFrame.js +5 -6
- package/dist/features/preview/CamoxPreview.js +137 -120
- package/dist/features/preview/components/{AddBlockDialog.js → AddBlockSheet.js} +35 -32
- package/dist/features/preview/components/BlockActionsPopover.js +6 -6
- package/dist/features/preview/components/BlockThumbnail.js +31 -33
- package/dist/features/preview/components/Overlays.js +1 -1
- package/dist/features/preview/components/PageTree.js +1 -1
- package/dist/features/preview/components/PreviewPanel.js +1 -1
- package/dist/features/preview/components/PreviewToolbar.js +74 -85
- package/dist/features/preview/previewStore.js +9 -9
- package/dist/features/provider/CamoxProvider.js +8 -16
- package/dist/features/provider/CoreCamoxProvider.js +10 -12
- package/dist/features/provider/signInShortcut.js +60 -0
- package/dist/features/routes/pageRuntime.js +8 -8
- package/dist/features/runtime/RuntimeChrome.js +1 -1
- package/dist/features/runtime/pageApp.js +11 -39
- package/dist/features/runtime/runtime.d.ts +2 -7
- package/dist/features/runtime/runtime.js +6 -19
- package/dist/features/studio/FollowAgentProvider.js +11 -22
- package/dist/features/studio/components/FaviconDialog.js +3 -3
- package/dist/features/studio/followAgent.js +5 -14
- package/dist/features/studio/routes.js +1 -23
- package/dist/lib/auth.js +36 -24
- package/dist/lib/studio-reads.js +0 -20
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +4 -4
- package/skills/camox-expand/SKILL.md +5 -4
- package/dist/features/canvas/CanvasBlockFrame.js +0 -353
- package/dist/features/canvas/CanvasBlockHeader.js +0 -55
- package/dist/features/canvas/CanvasShelfMarker.js +0 -255
- package/dist/features/canvas/sidebar/CatalogBlockInspector.js +0 -189
- package/dist/features/provider/LocalhostPreviewProvider.js +0 -158
|
@@ -17,10 +17,11 @@ import { canvasStore } from "../canvas/canvasStore.js";
|
|
|
17
17
|
import { SHOW_WHOLE_CANVAS_SHORTCUT, TOGGLE_CANVAS_SHORTCUT } from "./previewConstants.js";
|
|
18
18
|
import { CanvasSidebarSkeleton } from "../canvas/sidebar/CanvasSidebarSkeleton.js";
|
|
19
19
|
import { DerivedPageContent } from "../page/DerivedPageContent.js";
|
|
20
|
+
import { takeShowCanvasRequest } from "../provider/signInShortcut.js";
|
|
20
21
|
import { STUDIO_CANVAS_PATH } from "../studio/routes.js";
|
|
21
22
|
import { studioStore } from "../studio/studioStore.js";
|
|
22
23
|
import { previewStore, selectIsCanvasShown } from "./previewStore.js";
|
|
23
|
-
import {
|
|
24
|
+
import { AddBlockSheet } from "./components/AddBlockSheet.js";
|
|
24
25
|
import { CanvasPreview, prefetchCanvas } from "./components/CanvasPreview.js";
|
|
25
26
|
import { CreatePageModal } from "./components/CreatePageModal.js";
|
|
26
27
|
import { PreviewEditingOwnerContext } from "./previewSelection.js";
|
|
@@ -617,7 +618,7 @@ function usePrefetchCanvas(enabled, projectUuid) {
|
|
|
617
618
|
}
|
|
618
619
|
/** Studio chrome is shared; only curated previews require a Camox page record. */
|
|
619
620
|
const PreviewShell = (t0) => {
|
|
620
|
-
const $ = c(
|
|
621
|
+
const $ = c(53);
|
|
621
622
|
const { children, pageData, derivedLayout, pageLocation, canvasOnly, runtimeBasePath: t1 } = t0;
|
|
622
623
|
const runtimeBasePath = t1 === void 0 ? "" : t1;
|
|
623
624
|
const isAuthenticated = useIsAuthenticated();
|
|
@@ -663,26 +664,42 @@ const PreviewShell = (t0) => {
|
|
|
663
664
|
const editingOwner = t2;
|
|
664
665
|
let t3;
|
|
665
666
|
let t4;
|
|
666
|
-
if ($[4] !== isMobileStudio) {
|
|
667
|
+
if ($[4] !== isAuthenticated || $[5] !== isMobileStudio) {
|
|
667
668
|
t3 = () => {
|
|
668
|
-
if (!isMobileStudio)
|
|
669
|
-
previewStore.send({ type: "hideCanvas" });
|
|
670
|
-
previewStore.send({ type: "closeAddBlockDialog" });
|
|
669
|
+
if (isAuthenticated && takeShowCanvasRequest() && !isMobileStudio) previewStore.send({ type: "showCanvas" });
|
|
671
670
|
};
|
|
672
|
-
t4 = [isMobileStudio];
|
|
673
|
-
$[4] =
|
|
674
|
-
$[5] =
|
|
675
|
-
$[6] =
|
|
671
|
+
t4 = [isAuthenticated, isMobileStudio];
|
|
672
|
+
$[4] = isAuthenticated;
|
|
673
|
+
$[5] = isMobileStudio;
|
|
674
|
+
$[6] = t3;
|
|
675
|
+
$[7] = t4;
|
|
676
676
|
} else {
|
|
677
|
-
t3 = $[
|
|
678
|
-
t4 = $[
|
|
677
|
+
t3 = $[6];
|
|
678
|
+
t4 = $[7];
|
|
679
679
|
}
|
|
680
680
|
React.useEffect(t3, t4);
|
|
681
|
-
useCanvasOnlyLocation(!!canvasOnly && isAuthenticated, isCanvasShown, isMobileStudio, pageLocation);
|
|
682
681
|
let t5;
|
|
683
682
|
let t6;
|
|
684
|
-
if ($[
|
|
683
|
+
if ($[8] !== isMobileStudio) {
|
|
685
684
|
t5 = () => {
|
|
685
|
+
if (!isMobileStudio) return;
|
|
686
|
+
previewStore.send({ type: "hideCanvas" });
|
|
687
|
+
previewStore.send({ type: "closeAddBlockSheet" });
|
|
688
|
+
};
|
|
689
|
+
t6 = [isMobileStudio];
|
|
690
|
+
$[8] = isMobileStudio;
|
|
691
|
+
$[9] = t5;
|
|
692
|
+
$[10] = t6;
|
|
693
|
+
} else {
|
|
694
|
+
t5 = $[9];
|
|
695
|
+
t6 = $[10];
|
|
696
|
+
}
|
|
697
|
+
React.useEffect(t5, t6);
|
|
698
|
+
useCanvasOnlyLocation(!!canvasOnly && isAuthenticated, isCanvasShown, isMobileStudio, pageLocation);
|
|
699
|
+
let t7;
|
|
700
|
+
let t8;
|
|
701
|
+
if ($[11] !== isAuthenticated || $[12] !== isCanvasShown || $[13] !== isMobileStudio) {
|
|
702
|
+
t7 = () => {
|
|
686
703
|
const actions = [
|
|
687
704
|
{
|
|
688
705
|
id: "hide-canvas",
|
|
@@ -732,140 +749,140 @@ const PreviewShell = (t0) => {
|
|
|
732
749
|
});
|
|
733
750
|
};
|
|
734
751
|
};
|
|
735
|
-
|
|
752
|
+
t8 = [
|
|
736
753
|
isCanvasShown,
|
|
737
754
|
isAuthenticated,
|
|
738
755
|
isMobileStudio
|
|
739
756
|
];
|
|
740
|
-
$[
|
|
741
|
-
$[
|
|
742
|
-
$[
|
|
743
|
-
$[
|
|
744
|
-
$[
|
|
757
|
+
$[11] = isAuthenticated;
|
|
758
|
+
$[12] = isCanvasShown;
|
|
759
|
+
$[13] = isMobileStudio;
|
|
760
|
+
$[14] = t7;
|
|
761
|
+
$[15] = t8;
|
|
745
762
|
} else {
|
|
746
|
-
|
|
747
|
-
|
|
763
|
+
t7 = $[14];
|
|
764
|
+
t8 = $[15];
|
|
748
765
|
}
|
|
749
|
-
React.useEffect(
|
|
766
|
+
React.useEffect(t7, t8);
|
|
750
767
|
if (!isAuthenticated) {
|
|
751
|
-
let
|
|
752
|
-
if ($[
|
|
753
|
-
|
|
754
|
-
$[
|
|
755
|
-
$[
|
|
756
|
-
} else
|
|
757
|
-
return
|
|
768
|
+
let t9;
|
|
769
|
+
if ($[16] !== children) {
|
|
770
|
+
t9 = /* @__PURE__ */ jsx(Fragment, { children });
|
|
771
|
+
$[16] = children;
|
|
772
|
+
$[17] = t9;
|
|
773
|
+
} else t9 = $[17];
|
|
774
|
+
return t9;
|
|
758
775
|
}
|
|
759
|
-
const
|
|
760
|
-
let
|
|
761
|
-
if ($[
|
|
762
|
-
|
|
763
|
-
$[
|
|
764
|
-
$[
|
|
765
|
-
} else
|
|
766
|
-
const
|
|
767
|
-
const
|
|
768
|
-
const
|
|
769
|
-
let
|
|
770
|
-
if ($[
|
|
771
|
-
|
|
772
|
-
page:
|
|
773
|
-
layoutPage:
|
|
776
|
+
const t9 = !isCanvasShown && "bg-black";
|
|
777
|
+
let t10;
|
|
778
|
+
if ($[18] !== t9) {
|
|
779
|
+
t10 = cn("bg-background relative flex h-full min-h-0 flex-1 flex-col overflow-hidden", t9);
|
|
780
|
+
$[18] = t9;
|
|
781
|
+
$[19] = t10;
|
|
782
|
+
} else t10 = $[19];
|
|
783
|
+
const t11 = pageLocation?.pathname;
|
|
784
|
+
const t12 = !canvasOnly;
|
|
785
|
+
const t13 = !!derivedLayout;
|
|
786
|
+
let t14;
|
|
787
|
+
if ($[20] !== t12 || $[21] !== t13) {
|
|
788
|
+
t14 = /* @__PURE__ */ jsx(CanvasSidebarSkeleton, {
|
|
789
|
+
page: t12,
|
|
790
|
+
layoutPage: t13
|
|
774
791
|
});
|
|
775
|
-
$[
|
|
776
|
-
$[
|
|
777
|
-
$[
|
|
778
|
-
} else
|
|
779
|
-
const
|
|
780
|
-
const
|
|
781
|
-
const
|
|
782
|
-
const
|
|
783
|
-
let
|
|
784
|
-
if ($[
|
|
785
|
-
|
|
792
|
+
$[20] = t12;
|
|
793
|
+
$[21] = t13;
|
|
794
|
+
$[22] = t14;
|
|
795
|
+
} else t14 = $[22];
|
|
796
|
+
const t15 = !isCanvasEnabled;
|
|
797
|
+
const t16 = pageData?.page;
|
|
798
|
+
const t17 = derivedLayout?.layoutId;
|
|
799
|
+
const t18 = pageData?.projectName;
|
|
800
|
+
let t19;
|
|
801
|
+
if ($[23] !== children || $[24] !== isMobileStudio || $[25] !== pageLocation || $[26] !== t15 || $[27] !== t16 || $[28] !== t17 || $[29] !== t18) {
|
|
802
|
+
t19 = /* @__PURE__ */ jsx("div", {
|
|
786
803
|
className: "flex min-h-0 flex-1 flex-row items-stretch",
|
|
787
804
|
children: /* @__PURE__ */ jsx(PreviewPanel, {
|
|
788
|
-
active:
|
|
805
|
+
active: t15,
|
|
789
806
|
isMobileExperience: isMobileStudio,
|
|
790
|
-
page:
|
|
791
|
-
layoutId:
|
|
807
|
+
page: t16,
|
|
808
|
+
layoutId: t17,
|
|
792
809
|
pageLocation,
|
|
793
|
-
projectName:
|
|
810
|
+
projectName: t18,
|
|
794
811
|
children
|
|
795
812
|
})
|
|
796
813
|
});
|
|
797
|
-
$[
|
|
798
|
-
$[
|
|
799
|
-
$[
|
|
800
|
-
$[
|
|
801
|
-
$[
|
|
802
|
-
$[
|
|
803
|
-
$[
|
|
804
|
-
$[
|
|
805
|
-
} else
|
|
806
|
-
let
|
|
807
|
-
if ($[
|
|
808
|
-
|
|
814
|
+
$[23] = children;
|
|
815
|
+
$[24] = isMobileStudio;
|
|
816
|
+
$[25] = pageLocation;
|
|
817
|
+
$[26] = t15;
|
|
818
|
+
$[27] = t16;
|
|
819
|
+
$[28] = t17;
|
|
820
|
+
$[29] = t18;
|
|
821
|
+
$[30] = t19;
|
|
822
|
+
} else t19 = $[30];
|
|
823
|
+
let t20;
|
|
824
|
+
if ($[31] !== isCanvasEnabled || $[32] !== pathname || $[33] !== runtimeBasePath || $[34] !== t11 || $[35] !== t14 || $[36] !== t19) {
|
|
825
|
+
t20 = /* @__PURE__ */ jsx(CanvasPreview, {
|
|
809
826
|
enabled: isCanvasEnabled,
|
|
810
827
|
pathname,
|
|
811
|
-
pagePathname:
|
|
828
|
+
pagePathname: t11,
|
|
812
829
|
runtimeBasePath,
|
|
813
|
-
placeholder:
|
|
814
|
-
children:
|
|
830
|
+
placeholder: t14,
|
|
831
|
+
children: t19
|
|
815
832
|
});
|
|
816
|
-
$[
|
|
817
|
-
$[
|
|
818
|
-
$[
|
|
819
|
-
$[
|
|
820
|
-
$[
|
|
821
|
-
$[32] = t9;
|
|
822
|
-
$[33] = t18;
|
|
823
|
-
} else t18 = $[33];
|
|
824
|
-
let t19;
|
|
825
|
-
if ($[34] !== isCanvasEnabled || $[35] !== pageId) {
|
|
826
|
-
t19 = !isCanvasEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CreatePageModal, {}), pageId != null && /* @__PURE__ */ jsx(AddBlockDialog, {})] });
|
|
827
|
-
$[34] = isCanvasEnabled;
|
|
828
|
-
$[35] = pageId;
|
|
833
|
+
$[31] = isCanvasEnabled;
|
|
834
|
+
$[32] = pathname;
|
|
835
|
+
$[33] = runtimeBasePath;
|
|
836
|
+
$[34] = t11;
|
|
837
|
+
$[35] = t14;
|
|
829
838
|
$[36] = t19;
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
if ($[37] !== t18 || $[38] !== t19 || $[39] !== t8) {
|
|
833
|
-
t20 = /* @__PURE__ */ jsxs("div", {
|
|
834
|
-
className: t8,
|
|
835
|
-
children: [t18, t19]
|
|
836
|
-
});
|
|
837
|
-
$[37] = t18;
|
|
838
|
-
$[38] = t19;
|
|
839
|
-
$[39] = t8;
|
|
840
|
-
$[40] = t20;
|
|
841
|
-
} else t20 = $[40];
|
|
839
|
+
$[37] = t20;
|
|
840
|
+
} else t20 = $[37];
|
|
842
841
|
let t21;
|
|
843
|
-
if ($[
|
|
844
|
-
t21 = /* @__PURE__ */ jsx(
|
|
845
|
-
|
|
846
|
-
|
|
842
|
+
if ($[38] !== isCanvasEnabled || $[39] !== pageId) {
|
|
843
|
+
t21 = !isCanvasEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CreatePageModal, {}), pageId != null && /* @__PURE__ */ jsx(AddBlockSheet, {})] });
|
|
844
|
+
$[38] = isCanvasEnabled;
|
|
845
|
+
$[39] = pageId;
|
|
846
|
+
$[40] = t21;
|
|
847
|
+
} else t21 = $[40];
|
|
848
|
+
let t22;
|
|
849
|
+
if ($[41] !== t10 || $[42] !== t20 || $[43] !== t21) {
|
|
850
|
+
t22 = /* @__PURE__ */ jsxs("div", {
|
|
851
|
+
className: t10,
|
|
852
|
+
children: [t20, t21]
|
|
847
853
|
});
|
|
848
|
-
$[41] =
|
|
854
|
+
$[41] = t10;
|
|
849
855
|
$[42] = t20;
|
|
850
856
|
$[43] = t21;
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
if ($[44] !== projectUuid) {
|
|
854
|
-
t22 = /* @__PURE__ */ jsx(ContentCollectionItemSheet, { projectUuid });
|
|
855
|
-
$[44] = projectUuid;
|
|
856
|
-
$[45] = t22;
|
|
857
|
-
} else t22 = $[45];
|
|
857
|
+
$[44] = t22;
|
|
858
|
+
} else t22 = $[44];
|
|
858
859
|
let t23;
|
|
859
|
-
if ($[
|
|
860
|
-
t23 = /* @__PURE__ */
|
|
860
|
+
if ($[45] !== editingOwner || $[46] !== t22) {
|
|
861
|
+
t23 = /* @__PURE__ */ jsx(PreviewEditingOwnerContext, {
|
|
862
|
+
value: editingOwner,
|
|
863
|
+
children: t22
|
|
864
|
+
});
|
|
865
|
+
$[45] = editingOwner;
|
|
866
|
+
$[46] = t22;
|
|
867
|
+
$[47] = t23;
|
|
868
|
+
} else t23 = $[47];
|
|
869
|
+
let t24;
|
|
870
|
+
if ($[48] !== projectUuid) {
|
|
871
|
+
t24 = /* @__PURE__ */ jsx(ContentCollectionItemSheet, { projectUuid });
|
|
872
|
+
$[48] = projectUuid;
|
|
873
|
+
$[49] = t24;
|
|
874
|
+
} else t24 = $[49];
|
|
875
|
+
let t25;
|
|
876
|
+
if ($[50] !== t23 || $[51] !== t24) {
|
|
877
|
+
t25 = /* @__PURE__ */ jsxs(CollectionItemSheetProvider, {
|
|
861
878
|
onRouteTargetClose: _temp9,
|
|
862
|
-
children: [
|
|
879
|
+
children: [t23, t24]
|
|
863
880
|
});
|
|
864
|
-
$[
|
|
865
|
-
$[
|
|
866
|
-
$[
|
|
867
|
-
} else
|
|
868
|
-
return
|
|
881
|
+
$[50] = t23;
|
|
882
|
+
$[51] = t24;
|
|
883
|
+
$[52] = t25;
|
|
884
|
+
} else t25 = $[52];
|
|
885
|
+
return t25;
|
|
869
886
|
};
|
|
870
887
|
/** Zooms out to the whole Canvas, from anywhere in the site or the Studio. */
|
|
871
888
|
function useShowCanvasAction() {
|
|
@@ -14,12 +14,12 @@ import { generateKeyBetween } from "fractional-indexing";
|
|
|
14
14
|
import { useSelector } from "@xstate/store-react";
|
|
15
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
16
|
import { useMutation } from "@tanstack/react-query";
|
|
17
|
-
import {
|
|
17
|
+
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@camox/ui/sheet";
|
|
18
18
|
import { Badge } from "@camox/ui/badge";
|
|
19
19
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, commandFilter } from "@camox/ui/command";
|
|
20
20
|
|
|
21
|
-
//#region src/features/preview/components/
|
|
22
|
-
const
|
|
21
|
+
//#region src/features/preview/components/AddBlockSheet.tsx
|
|
22
|
+
const AddBlockSheet = ({ focusCreatedBlock = true }) => {
|
|
23
23
|
const [highlightedValue, setHighlightedValue] = React.useState("");
|
|
24
24
|
const [search, setSearch] = React.useState("");
|
|
25
25
|
const [error, setError] = React.useState(null);
|
|
@@ -32,7 +32,7 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
|
|
|
32
32
|
};
|
|
33
33
|
}, []);
|
|
34
34
|
const gridRef = React.useRef(null);
|
|
35
|
-
const
|
|
35
|
+
const sheet = useSelector(previewStore, (state) => state.context.addBlockSheet);
|
|
36
36
|
const studioCache = useStudioCache();
|
|
37
37
|
const projectUuid = useProjectUuid();
|
|
38
38
|
const pathname = useLocalePath();
|
|
@@ -117,15 +117,15 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
|
|
|
117
117
|
for (const block of pageBlocks) counts[block.type] = (counts[block.type] ?? 0) + 1;
|
|
118
118
|
return counts;
|
|
119
119
|
}, [page, pageBlocks]);
|
|
120
|
-
const [
|
|
121
|
-
if (
|
|
122
|
-
|
|
120
|
+
const [previousSheet, setPreviousSheet] = React.useState(sheet);
|
|
121
|
+
if (sheet !== previousSheet) {
|
|
122
|
+
setPreviousSheet(sheet);
|
|
123
123
|
setHighlightedValue("");
|
|
124
124
|
setSearch("");
|
|
125
125
|
setError(null);
|
|
126
126
|
}
|
|
127
127
|
const handleAddBlock = async (block) => {
|
|
128
|
-
if (!page || !
|
|
128
|
+
if (!page || !sheet || submitting.current) return;
|
|
129
129
|
submitting.current = true;
|
|
130
130
|
setError(null);
|
|
131
131
|
const owner = {
|
|
@@ -140,21 +140,21 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
|
|
|
140
140
|
type: block._internal.id,
|
|
141
141
|
content: bundle.content,
|
|
142
142
|
settings: bundle.settings,
|
|
143
|
-
afterPosition:
|
|
143
|
+
afterPosition: sheet.afterPosition,
|
|
144
144
|
repeatableItems: bundle.repeatableItems
|
|
145
145
|
});
|
|
146
146
|
const context = previewStore.getSnapshot().context;
|
|
147
147
|
if (!mounted.current) return;
|
|
148
148
|
if (focusCreatedBlock && !sameEditingOwner(context.editingContext, owner)) return;
|
|
149
|
-
if (context.
|
|
150
|
-
previewStore.send({ type: "
|
|
149
|
+
if (context.addBlockSheet !== sheet) return;
|
|
150
|
+
previewStore.send({ type: "closeAddBlockSheet" });
|
|
151
151
|
if (focusCreatedBlock) previewStore.send({
|
|
152
152
|
type: "focusCreatedBlock",
|
|
153
153
|
...owner,
|
|
154
154
|
blockId
|
|
155
155
|
});
|
|
156
156
|
} catch {
|
|
157
|
-
if (previewStore.getSnapshot().context.
|
|
157
|
+
if (previewStore.getSnapshot().context.addBlockSheet === sheet) setError("Could not add this block. Please try again.");
|
|
158
158
|
} finally {
|
|
159
159
|
submitting.current = false;
|
|
160
160
|
}
|
|
@@ -165,24 +165,25 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
|
|
|
165
165
|
const page = pageCounts[blockId] ?? "none";
|
|
166
166
|
return `${total} use${total > 1 ? "s" : ""} (${page} here)`;
|
|
167
167
|
};
|
|
168
|
-
return /* @__PURE__ */ jsx(
|
|
169
|
-
open:
|
|
168
|
+
return /* @__PURE__ */ jsx(Sheet, {
|
|
169
|
+
open: sheet != null,
|
|
170
170
|
onOpenChange: (open) => {
|
|
171
|
-
if (!open && !submitting.current) previewStore.send({ type: "
|
|
171
|
+
if (!open && !submitting.current) previewStore.send({ type: "closeAddBlockSheet" });
|
|
172
172
|
},
|
|
173
|
-
children: /* @__PURE__ */ jsxs(
|
|
174
|
-
|
|
173
|
+
children: /* @__PURE__ */ jsxs(SheetContent, {
|
|
174
|
+
side: "right",
|
|
175
|
+
className: "gap-0 overflow-hidden data-[side=right]:w-full data-[side=right]:sm:max-w-4xl",
|
|
175
176
|
children: [
|
|
176
|
-
/* @__PURE__ */ jsxs(
|
|
177
|
-
className: "pr-
|
|
178
|
-
children: [/* @__PURE__ */ jsx(
|
|
177
|
+
/* @__PURE__ */ jsxs(SheetHeader, {
|
|
178
|
+
className: "pr-12",
|
|
179
|
+
children: [/* @__PURE__ */ jsx(SheetTitle, { children: "Add a block" }), /* @__PURE__ */ jsx(SheetDescription, { children: "Search blocks, use the arrow keys to browse, and press Enter to add." })]
|
|
179
180
|
}),
|
|
180
181
|
/* @__PURE__ */ jsxs(Command, {
|
|
181
182
|
label: "Search blocks",
|
|
182
183
|
shouldFilter: false,
|
|
183
184
|
value: selectedValue,
|
|
184
185
|
onValueChange: setHighlightedValue,
|
|
185
|
-
className: "h-0 min-h-0 flex-1 rounded-none! bg-transparent!
|
|
186
|
+
className: "h-0 min-h-0 flex-1 rounded-none! bg-transparent! px-4! pt-0! pb-0!",
|
|
186
187
|
onKeyDown: (e) => {
|
|
187
188
|
if (e.nativeEvent.isComposing || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
188
189
|
if (![
|
|
@@ -214,11 +215,11 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
|
|
|
214
215
|
autoFocus: true
|
|
215
216
|
}), /* @__PURE__ */ jsxs(CommandList, {
|
|
216
217
|
label: "Available blocks",
|
|
217
|
-
className: "mt-4 max-h-none min-h-0 flex-1 pb-
|
|
218
|
+
className: "mt-4 max-h-none min-h-0 flex-1 pb-4",
|
|
218
219
|
"aria-busy": createBlock.isPending,
|
|
219
220
|
children: [/* @__PURE__ */ jsx(CommandEmpty, { children: "No blocks found." }), /* @__PURE__ */ jsx(CommandGroup, {
|
|
220
221
|
ref: gridRef,
|
|
221
|
-
className: "p-0 [&>[cmdk-group-items]]:grid [&>[cmdk-group-items]]:grid-cols-1 [&>[cmdk-group-items]]:gap-4
|
|
222
|
+
className: "@container p-0 [&>[cmdk-group-items]]:grid [&>[cmdk-group-items]]:grid-cols-1 [&>[cmdk-group-items]]:gap-4 @xl:[&>[cmdk-group-items]]:grid-cols-2 @3xl:[&>[cmdk-group-items]]:grid-cols-3",
|
|
222
223
|
children: filteredBlocks.map((block) => /* @__PURE__ */ jsxs(CommandItem, {
|
|
223
224
|
value: block._internal.id,
|
|
224
225
|
keywords: [block._internal.title, block._internal.description ?? ""],
|
|
@@ -252,14 +253,16 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
|
|
|
252
253
|
})]
|
|
253
254
|
})]
|
|
254
255
|
}),
|
|
255
|
-
createBlock.isPending && /* @__PURE__ */
|
|
256
|
-
|
|
257
|
-
children: "
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
256
|
+
(createBlock.isPending || error) && /* @__PURE__ */ jsxs("div", {
|
|
257
|
+
className: "border-border border-t p-4",
|
|
258
|
+
children: [createBlock.isPending && /* @__PURE__ */ jsx("p", {
|
|
259
|
+
role: "status",
|
|
260
|
+
children: "Adding block…"
|
|
261
|
+
}), error && /* @__PURE__ */ jsx("p", {
|
|
262
|
+
role: "alert",
|
|
263
|
+
className: "text-destructive",
|
|
264
|
+
children: error
|
|
265
|
+
})]
|
|
263
266
|
})
|
|
264
267
|
]
|
|
265
268
|
})
|
|
@@ -267,4 +270,4 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
|
|
|
267
270
|
};
|
|
268
271
|
|
|
269
272
|
//#endregion
|
|
270
|
-
export {
|
|
273
|
+
export { AddBlockSheet };
|
|
@@ -50,13 +50,13 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
|
|
|
50
50
|
const blockIndex = pageBlocks.findIndex((b) => b.id === block.id);
|
|
51
51
|
const afterPosition = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
|
|
52
52
|
previewStore.send({
|
|
53
|
-
type: "
|
|
53
|
+
type: "openAddBlockSheet",
|
|
54
54
|
afterPosition
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
57
|
const handleAddBlockBelow = (block) => {
|
|
58
58
|
previewStore.send({
|
|
59
|
-
type: "
|
|
59
|
+
type: "openAddBlockSheet",
|
|
60
60
|
afterPosition: block.position
|
|
61
61
|
});
|
|
62
62
|
};
|
|
@@ -104,7 +104,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
|
|
|
104
104
|
isLayoutBlock && layoutSlot === "before" && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsx(CommandItem, {
|
|
105
105
|
onSelect: () => {
|
|
106
106
|
previewStore.send({
|
|
107
|
-
type: "
|
|
107
|
+
type: "openAddBlockSheet",
|
|
108
108
|
afterPosition: ""
|
|
109
109
|
});
|
|
110
110
|
onOpenChange(false);
|
|
@@ -118,7 +118,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
|
|
|
118
118
|
onSelect: () => {
|
|
119
119
|
const lastPageBlock = pageBlocks[pageBlocks.length - 1];
|
|
120
120
|
previewStore.send({
|
|
121
|
-
type: "
|
|
121
|
+
type: "openAddBlockSheet",
|
|
122
122
|
afterPosition: lastPageBlock?.position
|
|
123
123
|
});
|
|
124
124
|
onOpenChange(false);
|
|
@@ -419,7 +419,7 @@ function useBlockActionsShortcuts() {
|
|
|
419
419
|
const block_2 = pageBlocks.find((b_6) => b_6.id === sel_7.blockId);
|
|
420
420
|
if (!block_2) return;
|
|
421
421
|
previewStore.send({
|
|
422
|
-
type: "
|
|
422
|
+
type: "openAddBlockSheet",
|
|
423
423
|
afterPosition: block_2.position
|
|
424
424
|
});
|
|
425
425
|
}
|
|
@@ -444,7 +444,7 @@ function useBlockActionsShortcuts() {
|
|
|
444
444
|
if (blockIndex === -1) return;
|
|
445
445
|
const afterPosition_1 = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
|
|
446
446
|
previewStore.send({
|
|
447
|
-
type: "
|
|
447
|
+
type: "openAddBlockSheet",
|
|
448
448
|
afterPosition: afterPosition_1
|
|
449
449
|
});
|
|
450
450
|
}
|
|
@@ -27,6 +27,7 @@ const ThumbnailFrame = (t0) => {
|
|
|
27
27
|
$[1] = t1;
|
|
28
28
|
} else t1 = $[1];
|
|
29
29
|
const bundle = t1;
|
|
30
|
+
const initialization = React.useRef(0);
|
|
30
31
|
let t2;
|
|
31
32
|
if ($[2] !== frame?.contentDocument || $[3] !== sourceDocument) {
|
|
32
33
|
t2 = () => {
|
|
@@ -38,8 +39,15 @@ const ThumbnailFrame = (t0) => {
|
|
|
38
39
|
const base = doc.createElement("base");
|
|
39
40
|
base.href = source.baseURI;
|
|
40
41
|
doc.head.appendChild(base);
|
|
42
|
+
const stylesheetsLoaded = [];
|
|
41
43
|
source.querySelectorAll("style, link[rel=\"stylesheet\"]").forEach((style) => {
|
|
42
|
-
if (isSiteStyle(style))
|
|
44
|
+
if (!isSiteStyle(style)) return;
|
|
45
|
+
const clone = style.cloneNode(true);
|
|
46
|
+
if (clone.localName === "link") stylesheetsLoaded.push(new Promise((resolve) => {
|
|
47
|
+
clone.addEventListener("load", resolve, { once: true });
|
|
48
|
+
clone.addEventListener("error", resolve, { once: true });
|
|
49
|
+
}));
|
|
50
|
+
doc.head.appendChild(clone);
|
|
43
51
|
});
|
|
44
52
|
if (source !== document) for (const [from, to] of [
|
|
45
53
|
[source.documentElement, doc.documentElement],
|
|
@@ -53,7 +61,10 @@ const ThumbnailFrame = (t0) => {
|
|
|
53
61
|
reset.textContent = "\n html, body { margin: 0 !important; overflow: hidden !important; }\n *, *::before, *::after {\n animation: none !important;\n transition: none !important;\n caret-color: transparent !important;\n }\n ";
|
|
54
62
|
doc.head.appendChild(reset);
|
|
55
63
|
doc.body.setAttribute("inert", "");
|
|
56
|
-
|
|
64
|
+
const generation = initialization.current = initialization.current + 1;
|
|
65
|
+
Promise.all(stylesheetsLoaded).then(() => {
|
|
66
|
+
if (initialization.current === generation) setRoot(mount);
|
|
67
|
+
});
|
|
57
68
|
};
|
|
58
69
|
$[2] = frame?.contentDocument;
|
|
59
70
|
$[3] = sourceDocument;
|
|
@@ -185,12 +196,11 @@ const ThumbnailFrame = (t0) => {
|
|
|
185
196
|
return t14;
|
|
186
197
|
};
|
|
187
198
|
const BlockThumbnail = (t0) => {
|
|
188
|
-
const $ = c(
|
|
199
|
+
const $ = c(11);
|
|
189
200
|
const { block, className } = t0;
|
|
190
201
|
const ref = React.useRef(null);
|
|
191
202
|
const [isVisible, setIsVisible] = React.useState(false);
|
|
192
203
|
const [width, setWidth] = React.useState(0);
|
|
193
|
-
const checkerSize = 8 * (1 + width / VIEWPORT_WIDTH);
|
|
194
204
|
let t1;
|
|
195
205
|
let t2;
|
|
196
206
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
@@ -222,46 +232,34 @@ const BlockThumbnail = (t0) => {
|
|
|
222
232
|
React.useEffect(t1, t2);
|
|
223
233
|
let t3;
|
|
224
234
|
if ($[2] !== className) {
|
|
225
|
-
t3 = cn("
|
|
235
|
+
t3 = cn("bg-muted pointer-events-none relative flex h-28 w-full items-center overflow-hidden", className);
|
|
226
236
|
$[2] = className;
|
|
227
237
|
$[3] = t3;
|
|
228
238
|
} else t3 = $[3];
|
|
229
239
|
let t4;
|
|
230
|
-
if ($[4] !==
|
|
231
|
-
t4 = width > 0
|
|
232
|
-
backgroundSize: `${checkerSize * 2}px ${checkerSize * 2}px`,
|
|
233
|
-
backgroundPosition: `0 0, 0 ${checkerSize}px, ${checkerSize}px ${-checkerSize}px, ${-checkerSize}px 0`
|
|
234
|
-
} : void 0;
|
|
235
|
-
$[4] = checkerSize;
|
|
236
|
-
$[5] = width;
|
|
237
|
-
$[6] = t4;
|
|
238
|
-
} else t4 = $[6];
|
|
239
|
-
let t5;
|
|
240
|
-
if ($[7] !== block || $[8] !== isVisible || $[9] !== width) {
|
|
241
|
-
t5 = isVisible && width > 0 && /* @__PURE__ */ jsx(ThumbnailFrame, {
|
|
240
|
+
if ($[4] !== block || $[5] !== isVisible || $[6] !== width) {
|
|
241
|
+
t4 = isVisible && width > 0 && /* @__PURE__ */ jsx(ThumbnailFrame, {
|
|
242
242
|
block,
|
|
243
243
|
width
|
|
244
244
|
});
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
} else
|
|
250
|
-
let
|
|
251
|
-
if ($[
|
|
252
|
-
|
|
245
|
+
$[4] = block;
|
|
246
|
+
$[5] = isVisible;
|
|
247
|
+
$[6] = width;
|
|
248
|
+
$[7] = t4;
|
|
249
|
+
} else t4 = $[7];
|
|
250
|
+
let t5;
|
|
251
|
+
if ($[8] !== t3 || $[9] !== t4) {
|
|
252
|
+
t5 = /* @__PURE__ */ jsx("div", {
|
|
253
253
|
ref,
|
|
254
254
|
className: t3,
|
|
255
|
-
style: t4,
|
|
256
255
|
"aria-hidden": "true",
|
|
257
|
-
children:
|
|
256
|
+
children: t4
|
|
258
257
|
});
|
|
259
|
-
$[
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return t6;
|
|
258
|
+
$[8] = t3;
|
|
259
|
+
$[9] = t4;
|
|
260
|
+
$[10] = t5;
|
|
261
|
+
} else t5 = $[10];
|
|
262
|
+
return t5;
|
|
265
263
|
};
|
|
266
264
|
|
|
267
265
|
//#endregion
|
|
@@ -835,7 +835,7 @@ function _temp3(block_3) {
|
|
|
835
835
|
return /* @__PURE__ */ jsx(SortableBlock, { block: block_3 }, block_3.id);
|
|
836
836
|
}
|
|
837
837
|
function _temp4() {
|
|
838
|
-
previewStore.send({ type: "
|
|
838
|
+
previewStore.send({ type: "openAddBlockSheet" });
|
|
839
839
|
}
|
|
840
840
|
|
|
841
841
|
//#endregion
|
|
@@ -478,7 +478,7 @@ const PreviewPanel = (t0) => {
|
|
|
478
478
|
$[43] = t19;
|
|
479
479
|
} else t19 = $[43];
|
|
480
480
|
const t20 = !placed && "inset-0";
|
|
481
|
-
const t21 = underCanvas &&
|
|
481
|
+
const t21 = underCanvas && !placed && "invisible";
|
|
482
482
|
const t22 = device && "checkered flex items-center justify-center";
|
|
483
483
|
let t23;
|
|
484
484
|
if ($[44] !== t20 || $[45] !== t21 || $[46] !== t22) {
|