camox 0.52.2 → 0.53.1
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/editing/createEditableBlock.js +1 -1
- package/dist/features/canvas/CamoxCanvas.js +103 -83
- package/dist/features/canvas/CanvasPageFrame.js +1 -1
- package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -1
- package/dist/features/canvas/canvasCamera.js +3 -3
- package/dist/features/canvas/sidebar/CanvasInspector.js +4 -159
- package/dist/features/canvas/sidebar/CanvasNavigator.js +41 -85
- package/dist/features/canvas/sidebar/CanvasSidebar.js +54 -32
- package/dist/features/canvas/sidebar/CanvasSidebarFrame.js +4 -3
- package/dist/features/canvas/sidebar/CanvasSidebarSkeleton.js +14 -6
- package/dist/features/canvas/sidebar/CanvasViewHeader.js +50 -0
- package/dist/features/canvas/sidebar/DerivedPageInspector.js +30 -18
- package/dist/features/canvas/sidebar/LayoutPageOverview.js +28 -11
- package/dist/features/canvas/sidebar/LayoutPageSeo.js +356 -0
- package/dist/features/canvas/sidebar/PageInspector.js +118 -80
- package/dist/features/canvas/sidebar/PageOverview.js +6 -1
- package/dist/features/canvas/sidebar/SingletonPageInspector.js +22 -14
- package/dist/features/canvas/useCanvasCamera.js +36 -39
- package/dist/features/preview/CamoxPreview.js +1 -1
- package/dist/features/preview/components/BlockActionsPopover.js +1 -1
- package/dist/features/preview/components/BlockThumbnail.js +1 -1
- package/dist/features/preview/components/CanvasPreview.js +1 -1
- package/dist/features/preview/components/CreatePageModal.js +1 -1
- package/dist/features/preview/components/ItemFieldsEditor.js +1 -1
- package/dist/features/preview/components/OverlayTracker.js +1 -1
- package/dist/features/preview/components/PageInfo.js +345 -228
- 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 +2 -2
- package/dist/features/preview/components/RepeatableItemsList.js +1 -1
- package/dist/features/preview/components/SelectionEditor.js +645 -655
- package/dist/features/preview/components/SidebarStack.js +553 -0
- package/dist/features/preview/components/StudioEditingFallback.js +2 -2
- package/dist/features/renderer/RendererFrames.js +34 -27
- package/dist/features/runtime/RuntimeChrome.js +1 -1
- package/dist/features/runtime/runtime.js +84 -26
- package/dist/features/studio/components/ChatSidebar.js +27 -19
- package/dist/features/studio/components/Navbar.js +1 -1
- package/dist/features/studio/components/UserButton.js +1 -1
- package/dist/lib/studio-reads.js +18 -0
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +4 -4
|
@@ -14,12 +14,12 @@ import { markdownToReactNodes } from "../lib/lexicalReact.js";
|
|
|
14
14
|
import { resolveReference, resolveReferenceList } from "../lib/reference.js";
|
|
15
15
|
import { referencePickerFocus } from "../../features/preview/referencePickerFocus.js";
|
|
16
16
|
import { selectionBlockId } from "../../features/preview/previewStore.js";
|
|
17
|
+
import { overlayFieldId, recordPlacementId } from "../../features/preview/overlayMessages.js";
|
|
17
18
|
import { useIsEditable } from "../hooks/useIsEditable.js";
|
|
18
19
|
import { CanvasWorkspaceContext } from "../../features/canvas/canvasZoom.js";
|
|
19
20
|
import { PreviewEditingOwnerContext, usePreviewSelection, usePreviewTargetSelection } from "../../features/preview/previewSelection.js";
|
|
20
21
|
import { useApplyContentEdit } from "./contentEdits.js";
|
|
21
22
|
import { useFrame } from "../../features/preview/components/Frame.js";
|
|
22
|
-
import { overlayFieldId, recordPlacementId } from "../../features/preview/overlayMessages.js";
|
|
23
23
|
import { useLatestRecord } from "./useLatestRecord.js";
|
|
24
24
|
import { registerRepeatableItem } from "../../features/preview/repeatableItemTargets.js";
|
|
25
25
|
import { revealScrollDelta } from "../../features/preview/selectionReveal.js";
|
|
@@ -41,6 +41,16 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
|
41
41
|
import { createStore as createStore$1 } from "@xstate/store";
|
|
42
42
|
|
|
43
43
|
//#region src/features/canvas/CamoxCanvas.tsx
|
|
44
|
+
/**
|
|
45
|
+
* The Canvas spans the studio under its sidebars, the Canvas sidebar on its left and the chat on
|
|
46
|
+
* its right: the camera frames and snaps Pages between them, and above the studio's bottom edge.
|
|
47
|
+
*/
|
|
48
|
+
const CANVAS_INSETS = {
|
|
49
|
+
top: 0,
|
|
50
|
+
right: 265,
|
|
51
|
+
bottom: 8,
|
|
52
|
+
left: 265
|
|
53
|
+
};
|
|
44
54
|
function usePreparationFailure(error, t0) {
|
|
45
55
|
const $ = c(5);
|
|
46
56
|
const selected = t0 === void 0 ? true : t0;
|
|
@@ -448,18 +458,32 @@ function CanvasPageFrameLoader(t0) {
|
|
|
448
458
|
} else t2 = $[22];
|
|
449
459
|
return t2;
|
|
450
460
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
461
|
+
/**
|
|
462
|
+
* How far a sidebar's scrim fades, in px: from this far inside the sidebar, to the edge of a
|
|
463
|
+
* snapped Page, past it by the page fit's padding.
|
|
464
|
+
*/
|
|
465
|
+
const SCRIM_FADE_INSIDE = 48;
|
|
466
|
+
/** How opaque the scrim gets at most: what's under it always shows through, faintly. */
|
|
467
|
+
const SCRIM_MAX_OPACITY = .8;
|
|
468
|
+
/** Opacity along the fade, relative to the most, eased so it leaves no visible edge where it ends. */
|
|
469
|
+
const SCRIM_EASING = [
|
|
470
|
+
1,
|
|
471
|
+
.92,
|
|
472
|
+
.78,
|
|
473
|
+
.6,
|
|
474
|
+
.42,
|
|
475
|
+
.26,
|
|
476
|
+
.13,
|
|
477
|
+
.05,
|
|
478
|
+
0
|
|
458
479
|
];
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
480
|
+
/** Fades what the Canvas shows around a sidebar into the Canvas's background, toward the sidebar. */
|
|
481
|
+
function scrimGradient(towards, inset) {
|
|
482
|
+
const from = inset - SCRIM_FADE_INSIDE;
|
|
483
|
+
const length = SCRIM_FADE_INSIDE + 16;
|
|
484
|
+
const stops = SCRIM_EASING.map((alpha, index) => `color-mix(in oklab, var(--color-muted) ${alpha * SCRIM_MAX_OPACITY * 100}%, transparent) ${from + length * index / (SCRIM_EASING.length - 1)}px`);
|
|
485
|
+
return `linear-gradient(to ${towards === "left" ? "right" : "left"}, ${stops.join(", ")})`;
|
|
486
|
+
}
|
|
463
487
|
/** A frame header above an item's slot, at a constant on-screen height. */
|
|
464
488
|
function CanvasHeaderSlot(t0) {
|
|
465
489
|
const $ = c(10);
|
|
@@ -775,7 +799,7 @@ function useWorkspaceThumbnails(workspaceKey) {
|
|
|
775
799
|
return thumbnails;
|
|
776
800
|
}
|
|
777
801
|
function CanvasWorkspace(t0) {
|
|
778
|
-
const $ = c(
|
|
802
|
+
const $ = c(42);
|
|
779
803
|
const { ref, pages, selectedPage, previewedPage, intendedPageKey, runtimeBasePath, viewport, onActivate, onSelectionIntent } = t0;
|
|
780
804
|
const { apiUrl, projectUuid } = useAuthContext();
|
|
781
805
|
const renamePage = useRenamePage();
|
|
@@ -865,8 +889,6 @@ function CanvasWorkspace(t0) {
|
|
|
865
889
|
const pageSlots = new Map(items.map(t6));
|
|
866
890
|
const framed = viewport.width < CANVAS_SLOT_WIDTH;
|
|
867
891
|
const snapTargets = canvasSnapTargets(items);
|
|
868
|
-
const snapRingRef = React.useRef(null);
|
|
869
|
-
const snapFlash = React.useRef(null);
|
|
870
892
|
let t7;
|
|
871
893
|
if ($[21] !== selectedPage?.key) {
|
|
872
894
|
t7 = (t8) => {
|
|
@@ -898,10 +920,7 @@ function CanvasWorkspace(t0) {
|
|
|
898
920
|
},
|
|
899
921
|
selected: intendedPageKey && pageSlots.has(intendedPageKey) ? intendedPageKey : null,
|
|
900
922
|
onDeselect: t8,
|
|
901
|
-
|
|
902
|
-
snapFlash.current = snapRingRef.current?.animate(SNAP_FLASH_KEYFRAMES, SNAP_FLASH_TIMING) ?? null;
|
|
903
|
-
},
|
|
904
|
-
onSnapStretched: () => snapFlash.current?.cancel(),
|
|
923
|
+
insets: CANVAS_INSETS,
|
|
905
924
|
onEditorMove: t9
|
|
906
925
|
});
|
|
907
926
|
let t10;
|
|
@@ -973,39 +992,56 @@ function CanvasWorkspace(t0) {
|
|
|
973
992
|
};
|
|
974
993
|
$[36] = t14;
|
|
975
994
|
} else t14 = $[36];
|
|
976
|
-
|
|
995
|
+
const t17 = [...pageSlots.values()].map((t16) => {
|
|
996
|
+
const { page: page_1, pathname: pathname_4, left: left_0 } = t16;
|
|
997
|
+
return /* @__PURE__ */ jsx(CanvasHeaderSlot, {
|
|
998
|
+
itemKey: page_1.key,
|
|
999
|
+
left: left_0,
|
|
1000
|
+
children: /* @__PURE__ */ jsx(CanvasPageHeader, {
|
|
1001
|
+
page: page_1,
|
|
1002
|
+
pathname: pathname_4,
|
|
1003
|
+
onRename: page_1.kind === "curated" ? (nickname) => renamePage(page_1.pageId, nickname) : void 0,
|
|
1004
|
+
selected: page_1.key === selectedPage?.key,
|
|
1005
|
+
onHoverChange: (hovered) => hover.send({
|
|
1006
|
+
type: "set",
|
|
1007
|
+
pageKey: hovered ? page_1.key : null
|
|
1008
|
+
}),
|
|
1009
|
+
onSelect: () => {
|
|
1010
|
+
if (!pathname_4) return;
|
|
1011
|
+
selectPage(pathname_4);
|
|
1012
|
+
},
|
|
1013
|
+
onChange: (path) => {
|
|
1014
|
+
const inLocale = localized(path);
|
|
1015
|
+
setPreviewPathnames((current) => ({
|
|
1016
|
+
...current,
|
|
1017
|
+
[page_1.key]: inLocale
|
|
1018
|
+
}));
|
|
1019
|
+
selectPage(inLocale);
|
|
1020
|
+
}
|
|
1021
|
+
})
|
|
1022
|
+
}, page_1.key);
|
|
1023
|
+
});
|
|
1024
|
+
let t18;
|
|
977
1025
|
if ($[37] !== pages.length) {
|
|
978
|
-
|
|
1026
|
+
t18 = !pages.length && /* @__PURE__ */ jsx(CanvasMessage, { children: "No pages to preview yet." });
|
|
979
1027
|
$[37] = pages.length;
|
|
980
|
-
$[38] =
|
|
981
|
-
} else
|
|
982
|
-
let
|
|
1028
|
+
$[38] = t18;
|
|
1029
|
+
} else t18 = $[38];
|
|
1030
|
+
let t19;
|
|
983
1031
|
if ($[39] !== instructionsId) {
|
|
984
|
-
|
|
1032
|
+
t19 = /* @__PURE__ */ jsx("p", {
|
|
985
1033
|
id: instructionsId,
|
|
986
1034
|
className: "sr-only",
|
|
987
1035
|
children: "Scroll, or hold Space and drag, to pan. Pinch or Ctrl/⌘ + scroll to zoom. Click a page to edit it. Focus the canvas and use plus or minus to zoom, arrow keys to pan, 0 for 100%, or Home / Shift+1 to fit all pages."
|
|
988
1036
|
});
|
|
989
1037
|
$[39] = instructionsId;
|
|
990
|
-
$[40] =
|
|
991
|
-
} else
|
|
992
|
-
let t19;
|
|
993
|
-
if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
|
|
994
|
-
t19 = { zIndex: 2 };
|
|
995
|
-
$[41] = t19;
|
|
996
|
-
} else t19 = $[41];
|
|
1038
|
+
$[40] = t19;
|
|
1039
|
+
} else t19 = $[40];
|
|
997
1040
|
let t20;
|
|
998
|
-
if ($[
|
|
999
|
-
t20 =
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
"data-canvas-snap-ring": true,
|
|
1003
|
-
className: "ring-primary pointer-events-none absolute inset-0 opacity-0 ring-3 ring-inset",
|
|
1004
|
-
style: t19
|
|
1005
|
-
});
|
|
1006
|
-
$[42] = snapRingRef;
|
|
1007
|
-
$[43] = t20;
|
|
1008
|
-
} else t20 = $[43];
|
|
1041
|
+
if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1042
|
+
t20 = ["left", "right"].map(_temp3);
|
|
1043
|
+
$[41] = t20;
|
|
1044
|
+
} else t20 = $[41];
|
|
1009
1045
|
return /* @__PURE__ */ jsxs("div", {
|
|
1010
1046
|
ref: viewportRef,
|
|
1011
1047
|
role: "region",
|
|
@@ -1046,48 +1082,32 @@ function CanvasWorkspace(t0) {
|
|
|
1046
1082
|
})
|
|
1047
1083
|
})
|
|
1048
1084
|
}),
|
|
1049
|
-
[...pageSlots.values()].map((t16) => {
|
|
1050
|
-
const { page: page_1, pathname: pathname_4, left: left_0 } = t16;
|
|
1051
|
-
return /* @__PURE__ */ jsx(CanvasHeaderSlot, {
|
|
1052
|
-
itemKey: page_1.key,
|
|
1053
|
-
left: left_0,
|
|
1054
|
-
children: /* @__PURE__ */ jsx(CanvasPageHeader, {
|
|
1055
|
-
page: page_1,
|
|
1056
|
-
pathname: pathname_4,
|
|
1057
|
-
onRename: page_1.kind === "curated" ? (nickname) => renamePage(page_1.pageId, nickname) : void 0,
|
|
1058
|
-
selected: page_1.key === selectedPage?.key,
|
|
1059
|
-
onHoverChange: (hovered) => hover.send({
|
|
1060
|
-
type: "set",
|
|
1061
|
-
pageKey: hovered ? page_1.key : null
|
|
1062
|
-
}),
|
|
1063
|
-
onSelect: () => {
|
|
1064
|
-
if (!pathname_4) return;
|
|
1065
|
-
selectPage(pathname_4);
|
|
1066
|
-
},
|
|
1067
|
-
onChange: (path) => {
|
|
1068
|
-
const inLocale = localized(path);
|
|
1069
|
-
setPreviewPathnames((current) => ({
|
|
1070
|
-
...current,
|
|
1071
|
-
[page_1.key]: inLocale
|
|
1072
|
-
}));
|
|
1073
|
-
selectPage(inLocale);
|
|
1074
|
-
}
|
|
1075
|
-
})
|
|
1076
|
-
}, page_1.key);
|
|
1077
|
-
}),
|
|
1078
1085
|
t17,
|
|
1079
1086
|
t18,
|
|
1087
|
+
t19,
|
|
1080
1088
|
t20
|
|
1081
1089
|
]
|
|
1082
1090
|
});
|
|
1083
1091
|
}
|
|
1092
|
+
function _temp3(side) {
|
|
1093
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1094
|
+
"aria-hidden": true,
|
|
1095
|
+
"data-canvas-scrim": side,
|
|
1096
|
+
className: "pointer-events-none absolute inset-y-0",
|
|
1097
|
+
style: {
|
|
1098
|
+
[side]: 0,
|
|
1099
|
+
width: CANVAS_INSETS[side] + 16,
|
|
1100
|
+
background: scrimGradient(side, CANVAS_INSETS[side]),
|
|
1101
|
+
zIndex: 2
|
|
1102
|
+
}
|
|
1103
|
+
}, side);
|
|
1104
|
+
}
|
|
1084
1105
|
function CamoxCanvas(t0) {
|
|
1085
1106
|
const $ = c(68);
|
|
1086
1107
|
const { runtimeBasePath } = t0;
|
|
1087
1108
|
const layouts = useRoutableLayouts();
|
|
1088
|
-
const renamePage = useRenamePage();
|
|
1089
1109
|
const location = useLocation();
|
|
1090
|
-
const viewportMode = useSelector(previewStore,
|
|
1110
|
+
const viewportMode = useSelector(previewStore, _temp4);
|
|
1091
1111
|
const viewport = CANVAS_DEVICES[viewportMode === "full" ? "desktop" : viewportMode];
|
|
1092
1112
|
const [activeFrame, setActiveFrame] = React.useState(null);
|
|
1093
1113
|
const selectedPath = location.pathname;
|
|
@@ -1117,7 +1137,7 @@ function CamoxCanvas(t0) {
|
|
|
1117
1137
|
t3 = [];
|
|
1118
1138
|
$[4] = t3;
|
|
1119
1139
|
} else t3 = $[4];
|
|
1120
|
-
React.useEffect(
|
|
1140
|
+
React.useEffect(_temp6, t3);
|
|
1121
1141
|
const projectUuid = useProjectUuid();
|
|
1122
1142
|
let t4;
|
|
1123
1143
|
if ($[5] !== projectUuid) {
|
|
@@ -1284,19 +1304,19 @@ function CamoxCanvas(t0) {
|
|
|
1284
1304
|
$[37] = t17;
|
|
1285
1305
|
} else t17 = $[37];
|
|
1286
1306
|
let t18;
|
|
1287
|
-
if ($[38] !== editingOwner || $[39] !== intendedPage || $[40] !== pageRecord || $[41] !==
|
|
1307
|
+
if ($[38] !== editingOwner || $[39] !== intendedPage || $[40] !== pageRecord || $[41] !== runtimeBasePath || $[42] !== t16) {
|
|
1288
1308
|
t18 = /* @__PURE__ */ jsx(CanvasSidebar, {
|
|
1289
1309
|
page: intendedPage,
|
|
1290
1310
|
navigator: t16,
|
|
1291
1311
|
onShowWholeCanvas: t17,
|
|
1292
|
-
onRenamePage: renamePage,
|
|
1293
1312
|
owner: editingOwner,
|
|
1294
|
-
pageRecord
|
|
1313
|
+
pageRecord,
|
|
1314
|
+
runtimeBasePath
|
|
1295
1315
|
});
|
|
1296
1316
|
$[38] = editingOwner;
|
|
1297
1317
|
$[39] = intendedPage;
|
|
1298
1318
|
$[40] = pageRecord;
|
|
1299
|
-
$[41] =
|
|
1319
|
+
$[41] = runtimeBasePath;
|
|
1300
1320
|
$[42] = t16;
|
|
1301
1321
|
$[43] = t18;
|
|
1302
1322
|
} else t18 = $[43];
|
|
@@ -1372,7 +1392,7 @@ function CamoxCanvas(t0) {
|
|
|
1372
1392
|
let t25;
|
|
1373
1393
|
if ($[64] !== t13 || $[65] !== t20 || $[66] !== t24) {
|
|
1374
1394
|
t25 = /* @__PURE__ */ jsxs("div", {
|
|
1375
|
-
className: "flex min-h-0 flex-1 overflow-hidden",
|
|
1395
|
+
className: "relative flex min-h-0 flex-1 overflow-hidden",
|
|
1376
1396
|
children: [
|
|
1377
1397
|
t13,
|
|
1378
1398
|
t20,
|
|
@@ -1386,14 +1406,14 @@ function CamoxCanvas(t0) {
|
|
|
1386
1406
|
} else t25 = $[67];
|
|
1387
1407
|
return t25;
|
|
1388
1408
|
}
|
|
1389
|
-
function
|
|
1409
|
+
function _temp6() {
|
|
1390
1410
|
previewStore.send({ type: "clearSelection" });
|
|
1391
|
-
return
|
|
1411
|
+
return _temp5;
|
|
1392
1412
|
}
|
|
1393
|
-
function
|
|
1413
|
+
function _temp5() {
|
|
1394
1414
|
previewStore.send({ type: "clearSelection" });
|
|
1395
1415
|
}
|
|
1396
|
-
function
|
|
1416
|
+
function _temp4(state) {
|
|
1397
1417
|
return state.context.viewportMode;
|
|
1398
1418
|
}
|
|
1399
1419
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ArtifactsRunContext } from "../../core/hooks/useArtifactHost.js";
|
|
2
|
+
import { useEditingFrameClaim, useEditingOwner } from "../preview/editingFrame.js";
|
|
2
3
|
import { EditableSurfaceContext } from "../../core/hooks/useIsEditable.js";
|
|
3
4
|
import { PreviewEditingOwnerContext } from "../preview/previewSelection.js";
|
|
4
5
|
import { RendererSlot, useRendererHost } from "../renderer/RendererFrames.js";
|
|
5
|
-
import { useEditingFrameClaim, useEditingOwner } from "../preview/editingFrame.js";
|
|
6
6
|
import { PreviewDocumentContext } from "../runtime/PreviewDocumentContext.js";
|
|
7
7
|
import { PreviewPreparationContext } from "../preview/previewPreparation.js";
|
|
8
8
|
import { canvasPageHref, measureCanvasDocument } from "./canvasFrameDocument.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CanvasWorkspaceContext } from "./canvasZoom.js";
|
|
2
1
|
import { useEditingFrameClaim, useEditingOwner } from "../preview/editingFrame.js";
|
|
2
|
+
import { CanvasWorkspaceContext } from "./canvasZoom.js";
|
|
3
3
|
import { ViewportContinuityContext } from "../preview/viewportContinuity.js";
|
|
4
4
|
import { usePreviewPageFrame } from "../preview/previewPageFrame.js";
|
|
5
5
|
import { PreviewPreparationContext } from "../preview/previewPreparation.js";
|
|
@@ -16,7 +16,7 @@ function findCanvasSnapTarget(camera, viewport, targets) {
|
|
|
16
16
|
}
|
|
17
17
|
const CANVAS_PADDING = 64;
|
|
18
18
|
/** Screen-space inset of a Page snapped to fit the viewport's width. */
|
|
19
|
-
const CANVAS_PAGE_FIT_PADDING =
|
|
19
|
+
const CANVAS_PAGE_FIT_PADDING = 16;
|
|
20
20
|
const MAX_CANVAS_ZOOM = 2;
|
|
21
21
|
/**
|
|
22
22
|
* Below this, Pages are too small to read while every frame comes near the
|
|
@@ -142,11 +142,11 @@ function canvasVerticalRail(delta, time, previous) {
|
|
|
142
142
|
}
|
|
143
143
|
/** Start at the selected page's top, fitting its width rather than the whole site. */
|
|
144
144
|
function fitCanvasPage(viewport, page) {
|
|
145
|
-
const padding = Math.min(
|
|
145
|
+
const padding = Math.min(16, viewport.width / 4);
|
|
146
146
|
const scale = Math.max(Number.EPSILON, Math.min(2, (viewport.width - padding * 2) / Math.max(1, page.width)));
|
|
147
147
|
return {
|
|
148
148
|
x: (viewport.width - page.width * scale) / 2 - page.left * scale,
|
|
149
|
-
y: Math.min(
|
|
149
|
+
y: Math.min(68, viewport.height / 3),
|
|
150
150
|
scale
|
|
151
151
|
};
|
|
152
152
|
}
|
|
@@ -1,151 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../preview/components/PageNicknameField.js";
|
|
3
|
-
import { SHOW_WHOLE_CANVAS_SHORTCUT } from "../../preview/previewConstants.js";
|
|
1
|
+
import { SidebarStackHeader } from "../../preview/components/SidebarStack.js";
|
|
4
2
|
import { c } from "react/compiler-runtime";
|
|
5
|
-
import { jsx
|
|
6
|
-
import { Button } from "@camox/ui/button";
|
|
7
|
-
import { Minimize } from "lucide-react";
|
|
8
|
-
import { toast } from "@camox/ui/toaster";
|
|
9
|
-
import * as Tooltip$1 from "@camox/ui/tooltip";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
4
|
import { Skeleton } from "@camox/ui/skeleton";
|
|
11
5
|
|
|
12
6
|
//#region src/features/canvas/sidebar/CanvasInspector.tsx
|
|
13
|
-
/**
|
|
14
|
-
* A page nickname that reads as the header's title, and shows it can be edited on hover.
|
|
15
|
-
* Its border and padding are always there, transparent until hovered or focused, so they
|
|
16
|
-
* never move the text. Saves on Enter or blur; Escape puts the nickname back.
|
|
17
|
-
*/
|
|
18
|
-
function PageNicknameInput(t0) {
|
|
19
|
-
const $ = c(11);
|
|
20
|
-
const { nickname, onRename } = t0;
|
|
21
|
-
let t1;
|
|
22
|
-
if ($[0] !== nickname || $[1] !== onRename) {
|
|
23
|
-
t1 = async (input) => {
|
|
24
|
-
const next = input.value.trim();
|
|
25
|
-
if (next === nickname) return;
|
|
26
|
-
if (!next) {
|
|
27
|
-
toast.error("Page nickname is required");
|
|
28
|
-
input.value = nickname;
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
await onRename(next);
|
|
33
|
-
} catch {
|
|
34
|
-
toast.error("Could not update page");
|
|
35
|
-
input.value = nickname;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
$[0] = nickname;
|
|
39
|
-
$[1] = onRename;
|
|
40
|
-
$[2] = t1;
|
|
41
|
-
} else t1 = $[2];
|
|
42
|
-
const save = t1;
|
|
43
|
-
let t2;
|
|
44
|
-
if ($[3] !== save) {
|
|
45
|
-
t2 = (event) => void save(event.currentTarget);
|
|
46
|
-
$[3] = save;
|
|
47
|
-
$[4] = t2;
|
|
48
|
-
} else t2 = $[4];
|
|
49
|
-
let t3;
|
|
50
|
-
if ($[5] !== nickname) {
|
|
51
|
-
t3 = (event_0) => {
|
|
52
|
-
event_0.stopPropagation();
|
|
53
|
-
if (event_0.key === "Enter") {
|
|
54
|
-
event_0.preventDefault();
|
|
55
|
-
event_0.currentTarget.blur();
|
|
56
|
-
}
|
|
57
|
-
if (event_0.key === "Escape") {
|
|
58
|
-
event_0.currentTarget.value = nickname;
|
|
59
|
-
event_0.currentTarget.blur();
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
$[5] = nickname;
|
|
63
|
-
$[6] = t3;
|
|
64
|
-
} else t3 = $[6];
|
|
65
|
-
let t4;
|
|
66
|
-
if ($[7] !== nickname || $[8] !== t2 || $[9] !== t3) {
|
|
67
|
-
t4 = /* @__PURE__ */ jsx("input", {
|
|
68
|
-
"aria-label": "Page nickname",
|
|
69
|
-
defaultValue: nickname,
|
|
70
|
-
title: nickname,
|
|
71
|
-
maxLength: 80,
|
|
72
|
-
className: "hover:border-input focus-visible:border-ring focus-visible:ring-ring/50 -mx-1.5 h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm font-medium transition-[color,box-shadow,border-color] outline-none hover:shadow-xs focus-visible:ring-3",
|
|
73
|
-
onBlur: t2,
|
|
74
|
-
onKeyDown: t3
|
|
75
|
-
}, nickname);
|
|
76
|
-
$[7] = nickname;
|
|
77
|
-
$[8] = t2;
|
|
78
|
-
$[9] = t3;
|
|
79
|
-
$[10] = t4;
|
|
80
|
-
} else t4 = $[10];
|
|
81
|
-
return t4;
|
|
82
|
-
}
|
|
83
|
-
const HEADER_CLASS_NAME = "border-border flex min-w-0 items-center gap-2.5 border-b p-2";
|
|
84
|
-
/** The item's name, beside a button that leaves the selection and zooms out to the whole Canvas. */
|
|
85
|
-
function CanvasInspectorHeader(t0) {
|
|
86
|
-
const $ = c(11);
|
|
87
|
-
const { onBack, children } = t0;
|
|
88
|
-
let t1;
|
|
89
|
-
if ($[0] !== onBack) {
|
|
90
|
-
t1 = /* @__PURE__ */ jsx(Button, {
|
|
91
|
-
type: "button",
|
|
92
|
-
variant: "outline",
|
|
93
|
-
size: "icon-sm",
|
|
94
|
-
"aria-label": "Show whole canvas",
|
|
95
|
-
onClick: onBack
|
|
96
|
-
});
|
|
97
|
-
$[0] = onBack;
|
|
98
|
-
$[1] = t1;
|
|
99
|
-
} else t1 = $[1];
|
|
100
|
-
let t2;
|
|
101
|
-
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
102
|
-
t2 = /* @__PURE__ */ jsx(Minimize, { className: "text-muted-foreground" });
|
|
103
|
-
$[2] = t2;
|
|
104
|
-
} else t2 = $[2];
|
|
105
|
-
let t3;
|
|
106
|
-
if ($[3] !== t1) {
|
|
107
|
-
t3 = /* @__PURE__ */ jsx(Tooltip$1.TooltipTrigger, {
|
|
108
|
-
render: t1,
|
|
109
|
-
children: t2
|
|
110
|
-
});
|
|
111
|
-
$[3] = t1;
|
|
112
|
-
$[4] = t3;
|
|
113
|
-
} else t3 = $[4];
|
|
114
|
-
let t4;
|
|
115
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
116
|
-
t4 = /* @__PURE__ */ jsxs(Tooltip$1.TooltipContent, {
|
|
117
|
-
side: "bottom",
|
|
118
|
-
children: ["Show whole canvas ", formatShortcut(SHOW_WHOLE_CANVAS_SHORTCUT)]
|
|
119
|
-
});
|
|
120
|
-
$[5] = t4;
|
|
121
|
-
} else t4 = $[5];
|
|
122
|
-
let t5;
|
|
123
|
-
if ($[6] !== t3) {
|
|
124
|
-
t5 = /* @__PURE__ */ jsxs(Tooltip$1.Tooltip, { children: [t3, t4] });
|
|
125
|
-
$[6] = t3;
|
|
126
|
-
$[7] = t5;
|
|
127
|
-
} else t5 = $[7];
|
|
128
|
-
let t6;
|
|
129
|
-
if ($[8] !== children || $[9] !== t5) {
|
|
130
|
-
t6 = /* @__PURE__ */ jsxs("header", {
|
|
131
|
-
className: HEADER_CLASS_NAME,
|
|
132
|
-
children: [t5, children]
|
|
133
|
-
});
|
|
134
|
-
$[8] = children;
|
|
135
|
-
$[9] = t5;
|
|
136
|
-
$[10] = t6;
|
|
137
|
-
} else t6 = $[10];
|
|
138
|
-
return t6;
|
|
139
|
-
}
|
|
140
7
|
/** Stands in for the header while the item loads, in its layout, so nothing shifts. */
|
|
141
8
|
function CanvasInspectorHeaderSkeleton() {
|
|
142
9
|
const $ = c(1);
|
|
143
10
|
let t0;
|
|
144
11
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
145
|
-
t0 = /* @__PURE__ */
|
|
146
|
-
className: HEADER_CLASS_NAME,
|
|
147
|
-
children: [/* @__PURE__ */ jsx(Skeleton, { className: "size-8" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-28" })]
|
|
148
|
-
});
|
|
12
|
+
t0 = /* @__PURE__ */ jsx(SidebarStackHeader, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-28" }) });
|
|
149
13
|
$[0] = t0;
|
|
150
14
|
} else t0 = $[0];
|
|
151
15
|
return t0;
|
|
@@ -164,25 +28,6 @@ function CanvasInspectorTitle(t0) {
|
|
|
164
28
|
} else t1 = $[1];
|
|
165
29
|
return t1;
|
|
166
30
|
}
|
|
167
|
-
/** A curated page's nickname as the title, which can be renamed in place. */
|
|
168
|
-
function CanvasInspectorNicknameTitle(t0) {
|
|
169
|
-
const $ = c(3);
|
|
170
|
-
const { nickname, onRename } = t0;
|
|
171
|
-
let t1;
|
|
172
|
-
if ($[0] !== nickname || $[1] !== onRename) {
|
|
173
|
-
t1 = /* @__PURE__ */ jsx("h2", {
|
|
174
|
-
className: "flex min-w-0 flex-1",
|
|
175
|
-
children: /* @__PURE__ */ jsx(PageNicknameInput, {
|
|
176
|
-
nickname,
|
|
177
|
-
onRename
|
|
178
|
-
})
|
|
179
|
-
});
|
|
180
|
-
$[0] = nickname;
|
|
181
|
-
$[1] = onRename;
|
|
182
|
-
$[2] = t1;
|
|
183
|
-
} else t1 = $[2];
|
|
184
|
-
return t1;
|
|
185
|
-
}
|
|
186
31
|
function CanvasInspectorBody(t0) {
|
|
187
32
|
const $ = c(2);
|
|
188
33
|
const { children } = t0;
|
|
@@ -199,4 +44,4 @@ function CanvasInspectorBody(t0) {
|
|
|
199
44
|
}
|
|
200
45
|
|
|
201
46
|
//#endregion
|
|
202
|
-
export { CanvasInspectorBody,
|
|
47
|
+
export { CanvasInspectorBody, CanvasInspectorHeaderSkeleton, CanvasInspectorTitle };
|