camox 0.76.0 → 0.76.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 +1077 -1681
- package/dist/core/editing/fieldSlot.js +251 -0
- package/dist/core/editing/useFieldSlot.js +159 -0
- package/dist/core/layoutContext.d.ts +2 -0
- package/dist/core/layoutContext.js +27 -1
- package/dist/features/canvas/CanvasPageFrame.js +2 -2
- package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -1
- package/dist/features/canvas/canvasCameraController.js +595 -0
- package/dist/features/canvas/useCanvasCamera.js +141 -587
- package/dist/features/canvas/useCanvasFrame.js +1 -1
- package/dist/features/page/DerivedPageContent.js +4 -8
- package/dist/features/preview/components/AssetLightbox.js +6 -65
- package/dist/features/preview/components/CanvasPreview.js +2 -2
- package/dist/features/preview/components/Frame.js +3 -3
- package/dist/features/preview/components/ItemFieldsEditor.js +376 -460
- package/dist/features/preview/components/Overlays.js +4 -9
- package/dist/features/preview/components/PreviewPanel.js +3 -3
- package/dist/features/preview/components/RemovedBlockPlaceholder.js +2 -2
- package/dist/features/preview/components/SelectionEditor.js +285 -339
- package/dist/features/preview/components/ZoomableImage.js +105 -0
- package/dist/features/preview/components/contentFieldSchema.js +3 -1
- package/dist/features/preview/components/useFieldWriter.js +30 -51
- package/dist/features/preview/components/useRecordView.js +3 -3
- package/dist/features/preview/overlayMessages.js +20 -58
- package/dist/features/preview/previewStore.js +6 -123
- package/dist/features/preview/repeatableItemPath.js +47 -0
- package/dist/features/renderer/RendererApp.js +6 -6
- package/dist/features/renderer/RendererFrames.js +2 -2
- package/dist/features/renderer/rendererHost.js +1 -1
- package/dist/features/routes/pageRuntime.d.ts +2 -8
- package/dist/features/routes/pageRuntime.js +21 -105
- package/dist/features/runtime/pageApp.js +1 -1
- package/dist/features/runtime/pageRead.js +105 -0
- package/dist/features/runtime/reader.d.ts +25 -0
- package/dist/features/runtime/reader.js +142 -0
- package/dist/features/runtime/runtime.d.ts +9 -3
- package/dist/features/runtime/runtime.js +608 -776
- package/dist/features/sdkBundle/buildSdkBundle.d.ts +5 -0
- package/dist/features/sdkBundle/buildSdkBundle.js +9 -3
- package/dist/features/studio/components/DraftsSheet.js +124 -65
- package/dist/features/studio/components/ThreadMessages.js +5 -9
- package/dist/features/studio/showInCanvas.js +9 -19
- package/dist/features/studio/useEditorSelection.js +8 -19
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +4 -4
- package/dist/core/hooks/useFieldSelection.js +0 -67
- package/dist/core/hooks/useIsEditable.js +0 -21
- package/dist/core/hooks/useOverlayMessage.js +0 -70
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NavigationProvider } from "../navigation/navigation.js";
|
|
2
|
+
import { FrameContext } from "../preview/components/Frame.js";
|
|
2
3
|
import { createCanvasDocument, observeCanvasDocument, pauseCanvasDocument, refreshCanvasDocument } from "./canvasFrameDocument.js";
|
|
3
4
|
import { useCanvasFrameInput } from "./useCanvasFrameInput.js";
|
|
4
|
-
import { FrameContext } from "../preview/components/Frame.js";
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useViewLocale } from "../../lib/view-locale-context.js";
|
|
2
2
|
import { usePageBlocks } from "../../lib/normalized-data.js";
|
|
3
|
-
import {
|
|
4
|
-
import { buildLayoutContext } from "../../core/layoutContext.js";
|
|
3
|
+
import { layoutPageContext } from "../../core/layoutContext.js";
|
|
5
4
|
import { SharedLayoutContent } from "./SharedLayoutContent.js";
|
|
6
5
|
import { c } from "react/compiler-runtime";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -30,15 +29,12 @@ function DerivedPageContent(t0) {
|
|
|
30
29
|
if (!layout) throw new Error(`Unknown derived layout: ${derived.layoutId}`);
|
|
31
30
|
const { page, result: t3 } = derived;
|
|
32
31
|
result = t3;
|
|
33
|
-
|
|
34
|
-
const collection = record && camoxApp.getCollectionById(record.collectionId);
|
|
35
|
-
t2 = buildLayoutContext(layout._internal, {
|
|
32
|
+
t2 = layoutPageContext(camoxApp, layout._internal, {
|
|
36
33
|
path: page?.path ?? "",
|
|
37
34
|
locale: locale.tag,
|
|
38
35
|
projectName: page?.projectName ?? "",
|
|
39
|
-
data: result?.data,
|
|
40
36
|
params: page?.params,
|
|
41
|
-
|
|
37
|
+
result
|
|
42
38
|
});
|
|
43
39
|
$[2] = camoxApp;
|
|
44
40
|
$[3] = derived;
|
|
@@ -51,7 +47,7 @@ function DerivedPageContent(t0) {
|
|
|
51
47
|
result = $[6];
|
|
52
48
|
t2 = $[7];
|
|
53
49
|
}
|
|
54
|
-
const context = t2;
|
|
50
|
+
const { context } = t2;
|
|
55
51
|
let t3;
|
|
56
52
|
if ($[8] !== afterBlocks || $[9] !== beforeBlocks) {
|
|
57
53
|
t3 = [...beforeBlocks, ...afterBlocks];
|
|
@@ -6,6 +6,7 @@ import { getApiUrl, getContentWriteHeaders } from "../../../lib/api-client.js";
|
|
|
6
6
|
import { fileMutations } from "../../../lib/queries.js";
|
|
7
7
|
import { DebouncedFieldEditor } from "./DebouncedFieldEditor.js";
|
|
8
8
|
import { Metadata, MetadataRow, formatRelativeTime } from "./Metadata.js";
|
|
9
|
+
import { ZoomableImage } from "./ZoomableImage.js";
|
|
9
10
|
import { c } from "react/compiler-runtime";
|
|
10
11
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
11
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -195,19 +196,7 @@ const AssetLightbox = ({ open, onOpenChange, fileId }) => {
|
|
|
195
196
|
const { data: usageCount } = useReadQuery(reads.fileUsageCount(fileId));
|
|
196
197
|
const [uploadState, setUploadState] = useState(null);
|
|
197
198
|
const replaceInputRef = useRef(null);
|
|
198
|
-
const containerRef = useRef(null);
|
|
199
|
-
const [zoomed, setZoomed] = useState(false);
|
|
200
|
-
const [zoomedWidth, setZoomedWidth] = useState(null);
|
|
201
|
-
const clickFractionRef = useRef(null);
|
|
202
199
|
const [deliveredSizes, setDeliveredSizes] = useState(null);
|
|
203
|
-
const [previousOpen, setPreviousOpen] = useState(open);
|
|
204
|
-
if (open !== previousOpen) {
|
|
205
|
-
setPreviousOpen(open);
|
|
206
|
-
if (!open) {
|
|
207
|
-
setZoomed(false);
|
|
208
|
-
setZoomedWidth(null);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
200
|
const isImage = file?.mimeType?.startsWith("image/") ?? false;
|
|
212
201
|
const isVideo = file?.mimeType?.startsWith("video/") ?? false;
|
|
213
202
|
const canUseAiMetadata = isRasterImage(file?.mimeType);
|
|
@@ -256,19 +245,6 @@ const AssetLightbox = ({ open, onOpenChange, fileId }) => {
|
|
|
256
245
|
fileMimeType,
|
|
257
246
|
fileSize
|
|
258
247
|
]);
|
|
259
|
-
useEffect(() => {
|
|
260
|
-
if (!zoomed || !zoomedWidth || !containerRef.current || !clickFractionRef.current) return;
|
|
261
|
-
const container = containerRef.current;
|
|
262
|
-
const img = container.querySelector("img");
|
|
263
|
-
if (!img) return;
|
|
264
|
-
requestAnimationFrame(() => {
|
|
265
|
-
const frac = clickFractionRef.current;
|
|
266
|
-
const scrollX = img.offsetLeft + img.width * frac.x - container.clientWidth / 2;
|
|
267
|
-
const scrollY = img.offsetTop + img.height * frac.y - container.clientHeight / 2;
|
|
268
|
-
container.scrollTo(scrollX, scrollY);
|
|
269
|
-
clickFractionRef.current = null;
|
|
270
|
-
});
|
|
271
|
-
}, [zoomed, zoomedWidth]);
|
|
272
248
|
const handleReplaceDrop = useCallback(async (files) => {
|
|
273
249
|
const droppedFile = files[0];
|
|
274
250
|
if (!droppedFile) return;
|
|
@@ -366,46 +342,11 @@ const AssetLightbox = ({ open, onOpenChange, fileId }) => {
|
|
|
366
342
|
label: "Drop file to replace",
|
|
367
343
|
onDrop: handleReplaceDrop,
|
|
368
344
|
className: "h-full min-w-0 flex-1",
|
|
369
|
-
children: [isImage ? /* @__PURE__ */ jsx(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
if (!img) return;
|
|
375
|
-
if (!zoomed) {
|
|
376
|
-
const rect = img.getBoundingClientRect();
|
|
377
|
-
clickFractionRef.current = {
|
|
378
|
-
x: (e.clientX - rect.left) / rect.width,
|
|
379
|
-
y: (e.clientY - rect.top) / rect.height
|
|
380
|
-
};
|
|
381
|
-
const container = containerRef.current;
|
|
382
|
-
const scaleForWidth = container.clientWidth * 2.5 / img.clientWidth;
|
|
383
|
-
const scaleForHeight = container.clientHeight * 2.5 / img.clientHeight;
|
|
384
|
-
setZoomedWidth(img.clientWidth * Math.max(scaleForWidth, scaleForHeight));
|
|
385
|
-
setZoomed(true);
|
|
386
|
-
} else {
|
|
387
|
-
setZoomed(false);
|
|
388
|
-
setZoomedWidth(null);
|
|
389
|
-
containerRef.current?.scrollTo(0, 0);
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
children: zoomed ? /* @__PURE__ */ jsx("div", {
|
|
393
|
-
className: "flex min-h-full items-center justify-center",
|
|
394
|
-
children: /* @__PURE__ */ jsx("img", {
|
|
395
|
-
src: file.url,
|
|
396
|
-
alt: file.alt || file.filename || "",
|
|
397
|
-
className: "cursor-zoom-out",
|
|
398
|
-
style: { width: zoomedWidth ?? void 0 },
|
|
399
|
-
draggable: false
|
|
400
|
-
})
|
|
401
|
-
}) : /* @__PURE__ */ jsx("img", {
|
|
402
|
-
src: file.url,
|
|
403
|
-
alt: file.alt || file.filename || "",
|
|
404
|
-
className: "max-h-full max-w-full cursor-zoom-in object-contain shadow-lg",
|
|
405
|
-
draggable: false
|
|
406
|
-
})
|
|
407
|
-
}) : isVideo ? /* @__PURE__ */ jsx("div", {
|
|
408
|
-
className: "checkered absolute inset-0 flex items-center justify-center p-6",
|
|
345
|
+
children: [isImage ? open && /* @__PURE__ */ jsx(ZoomableImage, {
|
|
346
|
+
src: file.url,
|
|
347
|
+
alt: file.alt || file.filename || ""
|
|
348
|
+
}, file.url) : isVideo ? /* @__PURE__ */ jsx("div", {
|
|
349
|
+
className: "absolute inset-0 flex items-center justify-center p-6",
|
|
409
350
|
children: open && /* @__PURE__ */ jsx("video", {
|
|
410
351
|
src: file.url,
|
|
411
352
|
controls: true,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CanvasLoadingScreen } from "../../canvas/CanvasLoadingScreen.js";
|
|
2
|
-
import { PreviewPageFrame, PreviewPageFrameContext } from "../previewPageFrame.js";
|
|
3
|
-
import { PreviewPreparationContext } from "../previewPreparation.js";
|
|
4
2
|
import { ViewportContinuity, ViewportContinuityContext } from "../viewportContinuity.js";
|
|
5
3
|
import { PreviewActivationContext } from "./PreviewActivation.js";
|
|
4
|
+
import { PreviewPageFrame, PreviewPageFrameContext } from "../previewPageFrame.js";
|
|
5
|
+
import { PreviewPreparationContext } from "../previewPreparation.js";
|
|
6
6
|
import { c } from "react/compiler-runtime";
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useLocation, useNavigate } from "../../navigation/navigation.js";
|
|
2
2
|
import { cn } from "../../../lib/utils.js";
|
|
3
|
-
import { ViewportContinuityContext, capturePreviewAnchor, restorePreviewAnchor } from "../viewportContinuity.js";
|
|
4
|
-
import { PreviewActivationContext } from "./PreviewActivation.js";
|
|
5
|
-
import { EMPTY_PREVIEW_DOCUMENT, isSiteStyle, restyle } from "./previewStyles.js";
|
|
6
3
|
import { listenForLinkIntent } from "../../runtime/linkPrefetch.js";
|
|
7
4
|
import { PageViewportContext } from "../../runtime/pageViewport.js";
|
|
8
5
|
import { PreviewDocumentContext } from "../../runtime/PreviewDocumentContext.js";
|
|
6
|
+
import { ViewportContinuityContext, capturePreviewAnchor, restorePreviewAnchor } from "../viewportContinuity.js";
|
|
7
|
+
import { PreviewActivationContext } from "./PreviewActivation.js";
|
|
8
|
+
import { EMPTY_PREVIEW_DOCUMENT, isSiteStyle, restyle } from "./previewStyles.js";
|
|
9
9
|
import { c } from "react/compiler-runtime";
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|