camox 0.33.1 → 0.35.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/components/lexical/InlineLexicalEditor.js +1 -1
- package/dist/core/components/lexical/SidebarLexicalEditor.js +7 -7
- package/dist/core/components/lexical/TextLinkPopover.js +4 -4
- package/dist/core/createApp.d.ts +2 -1
- package/dist/core/createBlock.d.ts +5 -1451
- package/dist/core/createBlock.js +450 -1603
- package/dist/core/defineDocument.d.ts +7 -0
- package/dist/core/defineDocument.js +7 -0
- package/dist/core/editing/BlockEditingRuntime.js +36 -0
- package/dist/core/editing/CompleteBlockEditingRuntime.js +76 -0
- package/dist/core/editing/createEditableBlock.d.ts +1455 -0
- package/dist/core/editing/createEditableBlock.js +1751 -0
- package/dist/core/lib/lexicalState.js +1 -1
- package/dist/features/agent-chat/components/AgentChatSidebar.js +4 -4
- package/dist/features/agent-chat/components/AgentChatThread.js +5 -5
- package/dist/features/content/components/AssetCard.js +1 -1
- package/dist/features/navigation/navigation.d.ts +39 -0
- package/dist/features/navigation/navigation.js +231 -0
- package/dist/features/page/PublishedPageContent.js +236 -0
- package/dist/features/page/PublishedPageExperience.js +23 -0
- package/dist/features/preview/CamoxPreview.d.ts +4 -0
- package/dist/features/preview/CamoxPreview.js +16 -16
- package/dist/features/preview/EditablePageContent.js +3 -0
- package/dist/features/preview/EditablePageExperience.js +24 -0
- package/dist/features/preview/components/AddBlockSidebar.js +7 -7
- package/dist/features/preview/components/AssetFieldEditor.js +1 -1
- package/dist/features/preview/components/AssetLightbox.js +46 -110
- package/dist/features/preview/components/BlockActionsPopover.js +6 -6
- package/dist/features/preview/components/CreatePageModal.js +7 -7
- package/dist/features/preview/components/DebouncedFieldEditor.js +2 -2
- package/dist/features/preview/components/DraftSwitchDialog.js +1 -1
- package/dist/features/preview/components/FieldToolbar.js +4 -4
- package/dist/features/preview/components/Frame.js +1 -1
- package/dist/features/preview/components/ItemFieldsEditor.js +3 -3
- package/dist/features/preview/components/LeftSidebar.js +1 -1
- package/dist/features/preview/components/LinkFieldEditor.js +3 -3
- package/dist/features/preview/components/Metadata.js +87 -0
- package/dist/features/preview/components/MultipleAssetFieldEditor.js +1 -1
- package/dist/features/preview/components/OverlayTracker.js +3 -3
- package/dist/features/preview/components/Overlays.js +3 -3
- package/dist/features/preview/components/PageEditorSidebar.js +5 -5
- package/dist/features/preview/components/PageInfoSidebar.js +158 -74
- package/dist/features/preview/components/PageLocationFieldset.js +1 -1
- package/dist/features/preview/components/PageNavigatorSidebar.js +10 -10
- package/dist/features/preview/components/PageNicknameField.js +2 -2
- package/dist/features/preview/components/PagePicker.js +4 -4
- package/dist/features/preview/components/PageTree.js +3 -3
- package/dist/features/preview/components/PeekedBlock.js +2 -2
- package/dist/features/preview/components/PreviewPanel.js +2 -2
- package/dist/features/preview/components/PreviewToolbar.js +2 -2
- package/dist/features/preview/components/PublishDialog.js +2 -2
- package/dist/features/preview/components/RepeatableItemsList.js +1 -1
- package/dist/features/preview/components/RightSidebar.js +1 -1
- package/dist/features/preview/components/useRepeatableItemActions.js +1 -1
- package/dist/features/preview/components/useUpdateBlockPosition.js +4 -4
- package/dist/features/provider/AuthenticatedCamoxProvider.js +63 -0
- package/dist/features/provider/CamoxProvider.d.ts +5 -12
- package/dist/features/provider/CamoxProvider.js +81 -337
- package/dist/features/provider/CoreCamoxProvider.js +37 -0
- package/dist/features/provider/LocalhostPreviewProvider.js +159 -0
- package/dist/features/provider/components/CommandPalette.js +1 -1
- package/dist/features/provider/useAdminShortcuts.js +1 -1
- package/dist/features/routes/pageRuntime.js +6 -0
- package/dist/features/runtime/hydrationData.js +9 -0
- package/dist/features/runtime/pageApp.js +188 -0
- package/dist/features/runtime/pageClient.d.ts +6 -0
- package/dist/features/runtime/pageClient.js +20 -0
- package/dist/features/runtime/pageNavigation.js +170 -0
- package/dist/features/runtime/pageServer.d.ts +9 -0
- package/dist/features/runtime/pageServer.js +18 -0
- package/dist/features/runtime/runtime.d.ts +25 -0
- package/dist/features/runtime/runtime.js +44 -0
- package/dist/features/runtime/studioApp.d.ts +15 -0
- package/dist/features/runtime/studioApp.js +185 -0
- package/dist/features/runtime/studioClient.d.ts +6 -0
- package/dist/features/runtime/studioClient.js +20 -0
- package/dist/features/runtime/studioNavigation.js +115 -0
- package/dist/features/runtime/studioServer.d.ts +9 -0
- package/dist/features/runtime/studioServer.js +18 -0
- package/dist/features/studio/CamoxStudio.js +4 -4
- package/dist/features/studio/components/EnvironmentMenu.js +2 -2
- package/dist/features/studio/components/Navbar.js +7 -7
- package/dist/features/studio/components/ProjectMenu.js +9 -9
- package/dist/features/studio/components/UserButton.js +3 -3
- package/dist/features/studio/useTheme.js +1 -22
- package/dist/features/vite/appGeneration.js +16 -5
- package/dist/features/vite/blockBoilerplate.js +1 -1
- package/dist/features/vite/definitionsSync.js +4 -4
- package/dist/features/vite/routeGeneration.js +9 -156
- package/dist/features/vite/runtimeDev.js +291 -0
- package/dist/features/vite/utils.js +3 -1
- package/dist/features/vite/vite.d.ts +22 -3
- package/dist/features/vite/vite.js +42 -19
- package/dist/lib/auth.js +42 -68
- package/dist/lib/normalized-data.js +6 -6
- package/dist/lib/telemetry.js +1 -24
- package/dist/lib/utils.js +1 -1
- package/dist/lib/view-queries.js +28 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/Matches.d.ts +114 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/RouterProvider.d.ts +25 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/config.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/defer.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/fileRoute.d.ts +20 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/global.d.ts +8 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/hash-scroll.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/index.d.ts +18 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/link.d.ts +161 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/load-matches.d.ts +6 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/location.d.ts +54 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/lru-cache.d.ts +8 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/manifest.d.ts +32 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/new-process-route-tree.d.ts +115 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/not-found.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/redirect.d.ts +49 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/rewrite.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/root.d.ts +6 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/route.d.ts +343 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/routeInfo.d.ts +48 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/router.d.ts +695 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/searchMiddleware.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/searchParams.d.ts +5 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/RawStream.d.ts +38 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/seroval-plugins.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/transformer.d.ts +65 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/stores.d.ts +69 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/structuralSharing.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/typePrimitives.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useLoaderData.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useLoaderDeps.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useNavigate.d.ts +10 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useParams.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useRouteContext.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useSearch.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/utils.d.ts +28 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/validators.d.ts +49 -0
- package/package.json +39 -12
- package/skills/camox-block/SKILL.md +4 -4
- package/skills/camox-cli/SKILL.md +3 -3
- package/skills/camox-layout/SKILL.md +2 -2
- package/dist/features/routes/ogRoute.d.ts +0 -12
- package/dist/features/routes/ogRoute.js +0 -20
- package/dist/features/routes/pageRoute.d.ts +0 -48
- package/dist/features/routes/pageRoute.js +0 -254
- package/dist/lib/api-client.d.ts +0 -7
- package/dist/lib/queries.d.ts +0 -12
package/dist/core/createBlock.js
CHANGED
|
@@ -1,132 +1,100 @@
|
|
|
1
|
+
import { useLocation } from "../features/navigation/navigation.js";
|
|
1
2
|
import { useProjectSlug } from "../lib/auth.js";
|
|
2
|
-
import {
|
|
3
|
-
import { trackClientEvent } from "../lib/telemetry-client.js";
|
|
4
|
-
import { useFrame } from "../features/preview/components/Frame.js";
|
|
5
|
-
import { postOverlayMessage } from "../features/preview/overlayMessages.js";
|
|
6
|
-
import { previewStore } from "../features/preview/previewStore.js";
|
|
3
|
+
import { viewPageQueries, viewProjectQueries } from "../lib/view-queries.js";
|
|
7
4
|
import { isFileMarker, isItemMarker, resolveFileMarker, useNormalizedData } from "../lib/normalized-data.js";
|
|
8
|
-
import {
|
|
9
|
-
import { InlineLexicalEditor } from "./components/lexical/InlineLexicalEditor.js";
|
|
10
|
-
import { useFieldSelection } from "./hooks/useFieldSelection.js";
|
|
11
|
-
import { useIsEditable } from "./hooks/useIsEditable.js";
|
|
12
|
-
import { useOverlayMessage } from "./hooks/useOverlayMessage.js";
|
|
5
|
+
import { useBlockEditingRuntime } from "./editing/BlockEditingRuntime.js";
|
|
13
6
|
import { Type, resolveToMarkdown } from "./lib/contentType.js";
|
|
14
7
|
import { buildImageSrcSet, getDefaultImageSizes, getDefaultImageWidth, transformImageUrl } from "./lib/imageTransform.js";
|
|
15
8
|
import { markdownToReactNodes } from "./lib/lexicalReact.js";
|
|
16
9
|
import { c } from "react/compiler-runtime";
|
|
17
|
-
import { Input } from "@camox/ui/input";
|
|
18
|
-
import { Label } from "@camox/ui/label";
|
|
19
|
-
import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
|
|
20
10
|
import { Type as Type$1 } from "@sinclair/typebox";
|
|
21
|
-
import {
|
|
22
|
-
import { useLocation } from "@tanstack/react-router";
|
|
23
|
-
import { useSelector } from "@xstate/store-react";
|
|
11
|
+
import { useQuery } from "@tanstack/react-query";
|
|
24
12
|
import { generateKeyBetween } from "fractional-indexing";
|
|
25
13
|
import * as React from "react";
|
|
26
|
-
import {
|
|
27
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
28
15
|
|
|
29
16
|
//#region src/core/createBlock.tsx
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (
|
|
17
|
+
const ASSET_LIST_SELF_KEY = "__camox_asset_self__";
|
|
18
|
+
function normalizeLinkValue(value) {
|
|
19
|
+
if (value.type) return value;
|
|
20
|
+
return {
|
|
33
21
|
type: "external",
|
|
34
22
|
...value
|
|
35
23
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
* Hash-only and empty hrefs are anchored to `currentPathname` so TanStack Router's
|
|
42
|
-
* `<Link to>` builds the same `href` on SSR and client — bare `"#"` otherwise
|
|
43
|
-
* resolves inconsistently across environments, causing hydration mismatches.
|
|
44
|
-
*/
|
|
45
|
-
const resolveLinkHref = (link, pages, currentPathname) => {
|
|
46
|
-
if (link.type === "page") return (pages?.find((p) => String(p.id) === link.pageId))?.fullPath ?? currentPathname;
|
|
47
|
-
if (!link.href || link.href.startsWith("#")) return `${currentPathname}${link.href ?? ""}`;
|
|
24
|
+
}
|
|
25
|
+
function resolveLinkHref(link, pages, pathname) {
|
|
26
|
+
if (link.type === "page") return pages?.find((page) => String(page.id) === link.pageId)?.fullPath ?? pathname;
|
|
27
|
+
if (!link.href || link.href.startsWith("#")) return `${pathname}${link.href ?? ""}`;
|
|
48
28
|
return link.href;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
function
|
|
56
|
-
for (const [fieldName,
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
if (ft === "ImageList" || ft === "FileList") continue;
|
|
60
|
-
const defaultCount = fieldSchema.defaultItems ?? fieldSchema.minItems ?? 0;
|
|
61
|
-
if (defaultCount <= 0) continue;
|
|
62
|
-
const itemProperties = fieldSchema.items.properties;
|
|
63
|
-
const itemContent = {};
|
|
64
|
-
for (const [propName, propSchema] of Object.entries(itemProperties)) {
|
|
65
|
-
if (propSchema.type === "array" && propSchema.items?.properties) continue;
|
|
66
|
-
if ("default" in propSchema) itemContent[propName] = propSchema.default;
|
|
67
|
-
}
|
|
68
|
-
const itemSettingsDefaults = fieldSchema.defaultItemSettings;
|
|
29
|
+
}
|
|
30
|
+
function collectDefaults(properties) {
|
|
31
|
+
const defaults = {};
|
|
32
|
+
for (const [key, property] of Object.entries(properties)) if ("default" in property) defaults[key] = property.default;
|
|
33
|
+
return defaults;
|
|
34
|
+
}
|
|
35
|
+
function buildInitialItems(properties, parentTempId, content, items, counter) {
|
|
36
|
+
for (const [fieldName, property] of Object.entries(properties)) {
|
|
37
|
+
if (property.type !== "array" || !property.items?.properties) continue;
|
|
38
|
+
if (property.fieldType === "ImageList" || property.fieldType === "FileList") continue;
|
|
69
39
|
const markers = [];
|
|
70
|
-
|
|
71
|
-
|
|
40
|
+
const defaultCount = Number(property.defaultItems ?? property.minItems ?? 0);
|
|
41
|
+
let previousPosition = null;
|
|
42
|
+
for (let index = 0; index < defaultCount; index += 1) {
|
|
72
43
|
const tempId = `seed_${++counter.value}`;
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
44
|
+
const itemContent = {};
|
|
45
|
+
for (const [key, itemProperty] of Object.entries(property.items.properties)) {
|
|
46
|
+
if (itemProperty.type === "array" && itemProperty.items?.properties) continue;
|
|
47
|
+
if ("default" in itemProperty) itemContent[key] = itemProperty.default;
|
|
48
|
+
}
|
|
49
|
+
const position = generateKeyBetween(previousPosition, null);
|
|
50
|
+
previousPosition = position;
|
|
51
|
+
items.push({
|
|
76
52
|
tempId,
|
|
77
53
|
parentTempId,
|
|
78
54
|
fieldName,
|
|
79
55
|
content: { ...itemContent },
|
|
80
|
-
settings:
|
|
56
|
+
...property.defaultItemSettings && { settings: { ...property.defaultItemSettings } },
|
|
81
57
|
position
|
|
82
58
|
});
|
|
59
|
+
buildInitialItems(property.items?.properties ?? {}, tempId, {}, items, counter);
|
|
83
60
|
markers.push({ _itemId: tempId });
|
|
84
|
-
buildInitialSeeds(itemProperties, tempId, {}, allSeeds, counter);
|
|
85
61
|
}
|
|
86
62
|
content[fieldName] = markers;
|
|
87
63
|
}
|
|
88
64
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
function buildPeekItems(properties, blockId, parentItemId, content, allItems, counter) {
|
|
95
|
-
for (const [fieldName, fieldSchema] of Object.entries(properties)) {
|
|
96
|
-
if (fieldSchema.type !== "array" || !fieldSchema.items?.properties) continue;
|
|
97
|
-
if (fieldSchema.fieldType === "ImageList" || fieldSchema.fieldType === "FileList") continue;
|
|
98
|
-
const defaultCount = fieldSchema.defaultItems ?? fieldSchema.minItems ?? 0;
|
|
99
|
-
if (defaultCount <= 0) continue;
|
|
100
|
-
const itemProperties = fieldSchema.items.properties;
|
|
101
|
-
const itemContent = {};
|
|
102
|
-
for (const [propName, propSchema] of Object.entries(itemProperties)) {
|
|
103
|
-
if (propSchema.type === "array" && propSchema.items?.properties) continue;
|
|
104
|
-
if ("default" in propSchema) itemContent[propName] = propSchema.default;
|
|
105
|
-
}
|
|
106
|
-
const itemSettingsDefaults = fieldSchema.defaultItemSettings;
|
|
65
|
+
function buildPeekItems(properties, blockId, parentItemId, content, items, counter) {
|
|
66
|
+
for (const [fieldName, property] of Object.entries(properties)) {
|
|
67
|
+
if (property.type !== "array" || !property.items?.properties) continue;
|
|
68
|
+
if (property.fieldType === "ImageList" || property.fieldType === "FileList") continue;
|
|
69
|
+
const defaultCount = Number(property.defaultItems ?? property.minItems ?? 0);
|
|
107
70
|
const markers = [];
|
|
108
|
-
let
|
|
109
|
-
for (let
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
71
|
+
let previousPosition = null;
|
|
72
|
+
for (let index = 0; index < defaultCount; index += 1) {
|
|
73
|
+
const id = --counter.value;
|
|
74
|
+
const itemContent = {};
|
|
75
|
+
for (const [key, itemProperty] of Object.entries(property.items.properties)) {
|
|
76
|
+
if (itemProperty.type === "array" && itemProperty.items?.properties) continue;
|
|
77
|
+
if ("default" in itemProperty) itemContent[key] = itemProperty.default;
|
|
78
|
+
}
|
|
79
|
+
const position = generateKeyBetween(previousPosition, null);
|
|
80
|
+
previousPosition = position;
|
|
81
|
+
items.push({
|
|
82
|
+
id,
|
|
115
83
|
blockId,
|
|
116
84
|
parentItemId,
|
|
117
85
|
fieldName,
|
|
118
|
-
content:
|
|
119
|
-
settings:
|
|
86
|
+
content: itemContent,
|
|
87
|
+
settings: property.defaultItemSettings ? { ...property.defaultItemSettings } : null,
|
|
120
88
|
summary: "",
|
|
121
89
|
position,
|
|
122
90
|
createdAt: 0,
|
|
123
91
|
updatedAt: 0
|
|
124
92
|
});
|
|
125
|
-
markers.push({ _itemId:
|
|
93
|
+
markers.push({ _itemId: id });
|
|
126
94
|
const nestedContent = {};
|
|
127
|
-
buildPeekItems(
|
|
128
|
-
const item =
|
|
129
|
-
item.content = {
|
|
95
|
+
buildPeekItems(property.items.properties, blockId, id, nestedContent, items, counter);
|
|
96
|
+
const item = items.find((candidate) => candidate.id === id);
|
|
97
|
+
if (item) item.content = {
|
|
130
98
|
...item.content,
|
|
131
99
|
...nestedContent
|
|
132
100
|
};
|
|
@@ -134,1510 +102,431 @@ function buildPeekItems(properties, blockId, parentItemId, content, allItems, co
|
|
|
134
102
|
content[fieldName] = markers;
|
|
135
103
|
}
|
|
136
104
|
}
|
|
137
|
-
function
|
|
105
|
+
function createViewBlock(options) {
|
|
138
106
|
const typeboxSchema = Type$1.Object(options.content);
|
|
139
|
-
const contentSchema = {
|
|
140
|
-
type: "object",
|
|
141
|
-
title: options.title,
|
|
142
|
-
description: options.description,
|
|
143
|
-
properties: typeboxSchema.properties,
|
|
144
|
-
required: Object.keys(options.content),
|
|
145
|
-
toMarkdown: resolveToMarkdown(options.toMarkdown, options.settings, "block")
|
|
146
|
-
};
|
|
147
107
|
const settingsTypeboxSchema = options.settings ? Type$1.Object(options.settings) : null;
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
contentDefaults[key] = prop.default;
|
|
157
|
-
const ft = prop.fieldType;
|
|
158
|
-
if (ft === "Image" || ft === "File" || ft === "ImageList" || ft === "FileList" || ft === "Repeater") continue;
|
|
159
|
-
contentDefaultsForStorage[key] = prop.default;
|
|
160
|
-
}
|
|
161
|
-
const repeatableItemDefaults = {};
|
|
162
|
-
const repeatableItemSettingsDefaults = {};
|
|
163
|
-
for (const [key, prop] of Object.entries(typeboxSchema.properties)) {
|
|
164
|
-
const p = prop;
|
|
165
|
-
if (p.type === "array" && p.items?.properties) {
|
|
166
|
-
const itemDefaults = {};
|
|
167
|
-
for (const [itemKey, itemProp] of Object.entries(p.items.properties)) if (itemProp && typeof itemProp === "object" && "default" in itemProp) itemDefaults[itemKey] = itemProp.default;
|
|
168
|
-
if (Object.keys(itemDefaults).length > 0) repeatableItemDefaults[key] = itemDefaults;
|
|
169
|
-
if (p.defaultItemSettings && typeof p.defaultItemSettings === "object") repeatableItemSettingsDefaults[key] = p.defaultItemSettings;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
const settingsDefaults = {};
|
|
173
|
-
if (settingsTypeboxSchema) {
|
|
174
|
-
for (const [key, prop] of Object.entries(settingsTypeboxSchema.properties)) if ("default" in prop) settingsDefaults[key] = prop.default;
|
|
108
|
+
const contentDefaults = collectDefaults(typeboxSchema.properties);
|
|
109
|
+
const settingsDefaults = settingsTypeboxSchema ? collectDefaults(settingsTypeboxSchema.properties) : {};
|
|
110
|
+
const repeatableDefaults = {};
|
|
111
|
+
const repeatableSettingsDefaults = {};
|
|
112
|
+
for (const [key, property] of Object.entries(typeboxSchema.properties)) {
|
|
113
|
+
if (property.fieldType !== "Repeater") continue;
|
|
114
|
+
repeatableDefaults[key] = collectDefaults(property.items?.properties ?? {});
|
|
115
|
+
repeatableSettingsDefaults[key] = { ...property.defaultItemSettings };
|
|
175
116
|
}
|
|
176
117
|
const Context = React.createContext(null);
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const getOverlayFieldId = (blockId, repeaterContext, fieldName) => {
|
|
185
|
-
if (repeaterContext?.itemId != null) return `${blockId}__${repeaterContext.itemId}__${fieldName}`;
|
|
186
|
-
return `${blockId}__${fieldName}`;
|
|
187
|
-
};
|
|
118
|
+
const RepeaterContext = React.createContext(null);
|
|
119
|
+
function useValue(name) {
|
|
120
|
+
const block = React.use(Context);
|
|
121
|
+
const item = React.use(RepeaterContext);
|
|
122
|
+
if (!block) throw new Error("Field must be used within a Block Component");
|
|
123
|
+
return item ? item.itemContent[name] : block.content[name];
|
|
124
|
+
}
|
|
188
125
|
const Field = ({ name, components, children }) => {
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
126
|
+
const editingRuntime = useBlockEditingRuntime();
|
|
127
|
+
if (editingRuntime) return editingRuntime.renderPrimitive(options, "Field", {
|
|
128
|
+
name,
|
|
129
|
+
components,
|
|
130
|
+
children
|
|
131
|
+
});
|
|
132
|
+
const value = useValue(name);
|
|
195
133
|
const projectSlug = useProjectSlug();
|
|
196
|
-
const { data: project } = useQuery(
|
|
134
|
+
const { data: project } = useQuery(viewProjectQueries.getBySlug(projectSlug));
|
|
197
135
|
const { data: pages } = useQuery({
|
|
198
|
-
...
|
|
136
|
+
...viewPageQueries.list(project?.id ?? 0),
|
|
199
137
|
enabled: !!project
|
|
200
138
|
});
|
|
201
|
-
|
|
202
|
-
const repeaterContext = React.use(RepeaterItemContext);
|
|
203
|
-
const fieldId = getOverlayFieldId(blockId, repeaterContext, String(name));
|
|
204
|
-
const fieldValue = repeaterContext ? repeaterContext.itemContent[name] : content[name];
|
|
205
|
-
const [isHovered, setIsHovered] = React.useState(false);
|
|
206
|
-
const [isEditorFocused, setIsEditorFocused] = React.useState(false);
|
|
207
|
-
const isSelectedFromSelection = useFieldSelection(blockId, String(name), "String", repeaterContext?.itemId);
|
|
208
|
-
const isFocused = isEditorFocused || isSelectedFromSelection;
|
|
209
|
-
const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", { fieldId });
|
|
210
|
-
React.useEffect(() => {
|
|
211
|
-
setIsHovered(isHoveredFromSidebar);
|
|
212
|
-
}, [isHoveredFromSidebar]);
|
|
213
|
-
const updateBlockContent = useMutation(blockMutations.updateContent());
|
|
214
|
-
const updateRepeatableContent = useMutation(repeatableItemMutations.updateContent());
|
|
215
|
-
const handleChange = React.useCallback((newValue) => {
|
|
216
|
-
if (repeaterContext) {
|
|
217
|
-
const { itemId } = repeaterContext;
|
|
218
|
-
if (itemId != null) updateRepeatableContent.mutate({
|
|
219
|
-
id: itemId,
|
|
220
|
-
content: { [name]: newValue }
|
|
221
|
-
});
|
|
222
|
-
} else updateBlockContent.mutate({
|
|
223
|
-
id: blockId,
|
|
224
|
-
content: { [name]: newValue }
|
|
225
|
-
});
|
|
226
|
-
}, [
|
|
227
|
-
blockId,
|
|
228
|
-
name,
|
|
229
|
-
repeaterContext,
|
|
230
|
-
updateBlockContent,
|
|
231
|
-
updateRepeatableContent
|
|
232
|
-
]);
|
|
233
|
-
const handleFocus = React.useCallback(() => {
|
|
234
|
-
setIsEditorFocused(true);
|
|
235
|
-
if (repeaterContext?.itemId != null) previewStore.send({
|
|
236
|
-
type: "selectItemField",
|
|
237
|
-
blockId,
|
|
238
|
-
itemId: repeaterContext.itemId,
|
|
239
|
-
fieldName: name.toString(),
|
|
240
|
-
fieldType: "String"
|
|
241
|
-
});
|
|
242
|
-
else previewStore.send({
|
|
243
|
-
type: "selectBlockField",
|
|
244
|
-
blockId,
|
|
245
|
-
fieldName: name.toString(),
|
|
246
|
-
fieldType: "String"
|
|
247
|
-
});
|
|
248
|
-
}, [
|
|
249
|
-
blockId,
|
|
250
|
-
name,
|
|
251
|
-
repeaterContext?.itemId
|
|
252
|
-
]);
|
|
253
|
-
const handleBlur = React.useCallback((wasEdited) => {
|
|
254
|
-
setIsEditorFocused(false);
|
|
255
|
-
if (wasEdited) trackClientEvent("block_edited", {
|
|
256
|
-
via: "inline-lexical",
|
|
257
|
-
blockType: options.id,
|
|
258
|
-
field: String(name)
|
|
259
|
-
});
|
|
260
|
-
}, [name]);
|
|
261
|
-
const handleMouseEnter = () => {
|
|
262
|
-
if (isContentEditable) setIsHovered(true);
|
|
263
|
-
};
|
|
264
|
-
const handleMouseLeave = () => {
|
|
265
|
-
if (isContentEditable) setIsHovered(false);
|
|
266
|
-
};
|
|
267
|
-
const fieldData = { text: fieldValue };
|
|
268
|
-
if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children({ children: markdownToReactNodes(fieldValue, {
|
|
139
|
+
return children({ children: markdownToReactNodes(value, {
|
|
269
140
|
pages,
|
|
270
|
-
fallbackHref:
|
|
141
|
+
fallbackHref: useLocation({ select: (location) => location.pathname }),
|
|
271
142
|
components
|
|
272
|
-
}) },
|
|
273
|
-
return /* @__PURE__ */ jsx(Fragment, { children: children({
|
|
274
|
-
ref: elementRef,
|
|
275
|
-
"data-camox-field-id": fieldId,
|
|
276
|
-
"data-camox-hovered": isHovered || void 0,
|
|
277
|
-
"data-camox-focused": isFocused || void 0,
|
|
278
|
-
"data-camox-overlay-mode": mode === "layout" ? "layout" : void 0,
|
|
279
|
-
onMouseEnter: handleMouseEnter,
|
|
280
|
-
onMouseLeave: handleMouseLeave,
|
|
281
|
-
children: /* @__PURE__ */ jsx(InlineLexicalEditor, {
|
|
282
|
-
initialState: fieldValue,
|
|
283
|
-
externalState: fieldValue,
|
|
284
|
-
onChange: handleChange,
|
|
285
|
-
onFocus: handleFocus,
|
|
286
|
-
onBlur: handleBlur
|
|
287
|
-
})
|
|
288
|
-
}, fieldData) });
|
|
143
|
+
}) }, { text: value });
|
|
289
144
|
};
|
|
290
|
-
const Embed = (
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
const
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
const { blockId, content, mode } = blockContext;
|
|
300
|
-
const isContentEditable = useIsEditable(mode);
|
|
301
|
-
const { window: iframeWindow } = useFrame();
|
|
302
|
-
const repeaterContext = React.use(RepeaterItemContext);
|
|
303
|
-
const fieldValue = repeaterContext ? repeaterContext.itemContent[name] : content[name];
|
|
304
|
-
const t1 = String(name);
|
|
305
|
-
let t2;
|
|
306
|
-
if ($[1] !== blockId || $[2] !== repeaterContext || $[3] !== t1) {
|
|
307
|
-
t2 = getOverlayFieldId(blockId, repeaterContext, t1);
|
|
308
|
-
$[1] = blockId;
|
|
309
|
-
$[2] = repeaterContext;
|
|
310
|
-
$[3] = t1;
|
|
311
|
-
$[4] = t2;
|
|
312
|
-
} else t2 = $[4];
|
|
313
|
-
const fieldId = t2;
|
|
314
|
-
const [isOpen, setIsOpen] = React.useState(false);
|
|
315
|
-
const [urlValue, setUrlValue] = React.useState(fieldValue);
|
|
316
|
-
const [isHovered, setIsHovered] = React.useState(false);
|
|
317
|
-
const timerRef = React.useRef(null);
|
|
318
|
-
let t3;
|
|
319
|
-
if ($[5] !== fieldId) {
|
|
320
|
-
t3 = { fieldId };
|
|
321
|
-
$[5] = fieldId;
|
|
322
|
-
$[6] = t3;
|
|
323
|
-
} else t3 = $[6];
|
|
324
|
-
const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t3);
|
|
325
|
-
let t4;
|
|
326
|
-
let t5;
|
|
327
|
-
if ($[7] !== isHoveredFromSidebar) {
|
|
328
|
-
t4 = () => {
|
|
329
|
-
setIsHovered(isHoveredFromSidebar);
|
|
330
|
-
};
|
|
331
|
-
t5 = [isHoveredFromSidebar];
|
|
332
|
-
$[7] = isHoveredFromSidebar;
|
|
333
|
-
$[8] = t4;
|
|
334
|
-
$[9] = t5;
|
|
335
|
-
} else {
|
|
336
|
-
t4 = $[8];
|
|
337
|
-
t5 = $[9];
|
|
338
|
-
}
|
|
339
|
-
React.useEffect(t4, t5);
|
|
340
|
-
let t6;
|
|
341
|
-
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
342
|
-
t6 = blockMutations.updateContent();
|
|
343
|
-
$[10] = t6;
|
|
344
|
-
} else t6 = $[10];
|
|
345
|
-
const updateBlockContent = useMutation(t6);
|
|
346
|
-
let t7;
|
|
347
|
-
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
348
|
-
t7 = repeatableItemMutations.updateContent();
|
|
349
|
-
$[11] = t7;
|
|
350
|
-
} else t7 = $[11];
|
|
351
|
-
const updateRepeatableContent = useMutation(t7);
|
|
352
|
-
let t8;
|
|
353
|
-
let t9;
|
|
354
|
-
if ($[12] !== fieldValue || $[13] !== isOpen) {
|
|
355
|
-
t8 = () => {
|
|
356
|
-
if (!isOpen) setUrlValue(fieldValue);
|
|
357
|
-
};
|
|
358
|
-
t9 = [fieldValue, isOpen];
|
|
359
|
-
$[12] = fieldValue;
|
|
360
|
-
$[13] = isOpen;
|
|
361
|
-
$[14] = t8;
|
|
362
|
-
$[15] = t9;
|
|
363
|
-
} else {
|
|
364
|
-
t8 = $[14];
|
|
365
|
-
t9 = $[15];
|
|
366
|
-
}
|
|
367
|
-
React.useEffect(t8, t9);
|
|
368
|
-
let t10;
|
|
369
|
-
let t11;
|
|
370
|
-
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
371
|
-
t10 = () => () => {
|
|
372
|
-
if (timerRef.current) clearTimeout(timerRef.current);
|
|
373
|
-
};
|
|
374
|
-
t11 = [];
|
|
375
|
-
$[16] = t10;
|
|
376
|
-
$[17] = t11;
|
|
377
|
-
} else {
|
|
378
|
-
t10 = $[16];
|
|
379
|
-
t11 = $[17];
|
|
380
|
-
}
|
|
381
|
-
React.useEffect(t10, t11);
|
|
382
|
-
let t12;
|
|
383
|
-
if ($[18] !== blockId || $[19] !== name || $[20] !== repeaterContext || $[21] !== updateBlockContent || $[22] !== updateRepeatableContent) {
|
|
384
|
-
t12 = (e) => {
|
|
385
|
-
const newValue = e.target.value;
|
|
386
|
-
setUrlValue(newValue);
|
|
387
|
-
if (timerRef.current) clearTimeout(timerRef.current);
|
|
388
|
-
timerRef.current = window.setTimeout(() => {
|
|
389
|
-
if (repeaterContext?.itemId != null) updateRepeatableContent.mutate({
|
|
390
|
-
id: repeaterContext.itemId,
|
|
391
|
-
content: { [name]: newValue }
|
|
392
|
-
});
|
|
393
|
-
else updateBlockContent.mutate({
|
|
394
|
-
id: blockId,
|
|
395
|
-
content: { [name]: newValue }
|
|
396
|
-
});
|
|
397
|
-
}, 500);
|
|
398
|
-
};
|
|
399
|
-
$[18] = blockId;
|
|
400
|
-
$[19] = name;
|
|
401
|
-
$[20] = repeaterContext;
|
|
402
|
-
$[21] = updateBlockContent;
|
|
403
|
-
$[22] = updateRepeatableContent;
|
|
404
|
-
$[23] = t12;
|
|
405
|
-
} else t12 = $[23];
|
|
406
|
-
const handleUrlChange = t12;
|
|
407
|
-
let t13;
|
|
408
|
-
if ($[24] !== blockId || $[25] !== name || $[26] !== repeaterContext) {
|
|
409
|
-
t13 = (open, _eventDetails) => {
|
|
410
|
-
setIsOpen(open);
|
|
411
|
-
if (open) if (repeaterContext?.itemId != null) previewStore.send({
|
|
412
|
-
type: "selectItemField",
|
|
413
|
-
blockId,
|
|
414
|
-
itemId: repeaterContext.itemId,
|
|
415
|
-
fieldName: name.toString(),
|
|
416
|
-
fieldType: "Embed"
|
|
417
|
-
});
|
|
418
|
-
else previewStore.send({
|
|
419
|
-
type: "selectBlockField",
|
|
420
|
-
blockId,
|
|
421
|
-
fieldName: name.toString(),
|
|
422
|
-
fieldType: "Embed"
|
|
423
|
-
});
|
|
424
|
-
};
|
|
425
|
-
$[24] = blockId;
|
|
426
|
-
$[25] = name;
|
|
427
|
-
$[26] = repeaterContext;
|
|
428
|
-
$[27] = t13;
|
|
429
|
-
} else t13 = $[27];
|
|
430
|
-
const handleOpenChange = t13;
|
|
431
|
-
const t14 = isContentEditable ? isOpen : false;
|
|
432
|
-
const t15 = isContentEditable ? handleOpenChange : void 0;
|
|
433
|
-
const t16 = isContentEditable ? fieldId : void 0;
|
|
434
|
-
const t17 = isContentEditable ? "embed" : void 0;
|
|
435
|
-
const t18 = isContentEditable && isHovered || void 0;
|
|
436
|
-
const t19 = isContentEditable && isOpen || void 0;
|
|
437
|
-
const t20 = mode === "layout" ? "layout" : void 0;
|
|
438
|
-
let t21;
|
|
439
|
-
if ($[28] !== isContentEditable) {
|
|
440
|
-
t21 = isContentEditable ? () => setIsHovered(true) : void 0;
|
|
441
|
-
$[28] = isContentEditable;
|
|
442
|
-
$[29] = t21;
|
|
443
|
-
} else t21 = $[29];
|
|
444
|
-
let t22;
|
|
445
|
-
if ($[30] !== isContentEditable) {
|
|
446
|
-
t22 = isContentEditable ? () => setIsHovered(false) : void 0;
|
|
447
|
-
$[30] = isContentEditable;
|
|
448
|
-
$[31] = t22;
|
|
449
|
-
} else t22 = $[31];
|
|
450
|
-
let t23;
|
|
451
|
-
if ($[32] !== t16 || $[33] !== t17 || $[34] !== t18 || $[35] !== t19 || $[36] !== t20 || $[37] !== t21 || $[38] !== t22) {
|
|
452
|
-
t23 = /* @__PURE__ */ jsx("div", {
|
|
453
|
-
"data-camox-field-id": t16,
|
|
454
|
-
"data-camox-field-type": t17,
|
|
455
|
-
"data-camox-hovered": t18,
|
|
456
|
-
"data-camox-focused": t19,
|
|
457
|
-
"data-camox-overlay-mode": t20,
|
|
458
|
-
onMouseEnter: t21,
|
|
459
|
-
onMouseLeave: t22
|
|
460
|
-
});
|
|
461
|
-
$[32] = t16;
|
|
462
|
-
$[33] = t17;
|
|
463
|
-
$[34] = t18;
|
|
464
|
-
$[35] = t19;
|
|
465
|
-
$[36] = t20;
|
|
466
|
-
$[37] = t21;
|
|
467
|
-
$[38] = t22;
|
|
468
|
-
$[39] = t23;
|
|
469
|
-
} else t23 = $[39];
|
|
470
|
-
let t24;
|
|
471
|
-
if ($[40] !== children || $[41] !== fieldValue) {
|
|
472
|
-
t24 = children({ src: fieldValue }, { url: fieldValue });
|
|
473
|
-
$[40] = children;
|
|
474
|
-
$[41] = fieldValue;
|
|
475
|
-
$[42] = t24;
|
|
476
|
-
} else t24 = $[42];
|
|
477
|
-
let t25;
|
|
478
|
-
if ($[43] !== isContentEditable) {
|
|
479
|
-
t25 = isContentEditable && /* @__PURE__ */ jsx("div", { style: {
|
|
480
|
-
position: "absolute",
|
|
481
|
-
inset: 0,
|
|
482
|
-
zIndex: 10
|
|
483
|
-
} });
|
|
484
|
-
$[43] = isContentEditable;
|
|
485
|
-
$[44] = t25;
|
|
486
|
-
} else t25 = $[44];
|
|
487
|
-
let t26;
|
|
488
|
-
if ($[45] !== t23 || $[46] !== t24 || $[47] !== t25) {
|
|
489
|
-
t26 = /* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
490
|
-
render: t23,
|
|
491
|
-
nativeButton: false,
|
|
492
|
-
children: [t24, t25]
|
|
493
|
-
});
|
|
494
|
-
$[45] = t23;
|
|
495
|
-
$[46] = t24;
|
|
496
|
-
$[47] = t25;
|
|
497
|
-
$[48] = t26;
|
|
498
|
-
} else t26 = $[48];
|
|
499
|
-
let t27;
|
|
500
|
-
if ($[49] !== handleUrlChange || $[50] !== isContentEditable || $[51] !== name || $[52] !== urlValue) {
|
|
501
|
-
t27 = isContentEditable && /* @__PURE__ */ jsx(PopoverContent, {
|
|
502
|
-
className: "w-96 gap-2",
|
|
503
|
-
children: /* @__PURE__ */ jsxs("form", {
|
|
504
|
-
className: "grid gap-2",
|
|
505
|
-
children: [/* @__PURE__ */ jsx(Label, {
|
|
506
|
-
htmlFor: "url",
|
|
507
|
-
children: options.content[name]?.title ?? String(name)
|
|
508
|
-
}), /* @__PURE__ */ jsx(Input, {
|
|
509
|
-
type: "url",
|
|
510
|
-
id: "url",
|
|
511
|
-
value: urlValue,
|
|
512
|
-
onChange: handleUrlChange
|
|
513
|
-
})]
|
|
514
|
-
})
|
|
515
|
-
});
|
|
516
|
-
$[49] = handleUrlChange;
|
|
517
|
-
$[50] = isContentEditable;
|
|
518
|
-
$[51] = name;
|
|
519
|
-
$[52] = urlValue;
|
|
520
|
-
$[53] = t27;
|
|
521
|
-
} else t27 = $[53];
|
|
522
|
-
let t28;
|
|
523
|
-
if ($[54] !== t14 || $[55] !== t15 || $[56] !== t26 || $[57] !== t27) {
|
|
524
|
-
t28 = /* @__PURE__ */ jsxs(Popover, {
|
|
525
|
-
open: t14,
|
|
526
|
-
onOpenChange: t15,
|
|
527
|
-
children: [t26, t27]
|
|
528
|
-
});
|
|
529
|
-
$[54] = t14;
|
|
530
|
-
$[55] = t15;
|
|
531
|
-
$[56] = t26;
|
|
532
|
-
$[57] = t27;
|
|
533
|
-
$[58] = t28;
|
|
534
|
-
} else t28 = $[58];
|
|
535
|
-
return t28;
|
|
145
|
+
const Embed = ({ name, children }) => {
|
|
146
|
+
const editingRuntime = useBlockEditingRuntime();
|
|
147
|
+
if (editingRuntime) return editingRuntime.renderPrimitive(options, "Embed", {
|
|
148
|
+
name,
|
|
149
|
+
children
|
|
150
|
+
});
|
|
151
|
+
const rawValue = useValue(name);
|
|
152
|
+
const value = typeof rawValue === "string" ? rawValue : "";
|
|
153
|
+
return children({ src: value }, { url: value });
|
|
536
154
|
};
|
|
537
|
-
const Link = (
|
|
538
|
-
const
|
|
539
|
-
if (
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
}
|
|
543
|
-
const
|
|
544
|
-
const blockContext = React.use(Context);
|
|
545
|
-
if (!blockContext) throw new Error("Link must be used within a Block Component");
|
|
546
|
-
const { blockId, content, mode } = blockContext;
|
|
547
|
-
const isContentEditable = useIsEditable(mode);
|
|
548
|
-
const elementRef = React.useRef(null);
|
|
549
|
-
const { window: iframeWindow } = useFrame();
|
|
550
|
-
const repeaterContext = React.use(RepeaterItemContext);
|
|
551
|
-
const fieldValue = normalizeLinkValue(repeaterContext ? repeaterContext.itemContent[name] : content[name]);
|
|
552
|
-
let t1;
|
|
553
|
-
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
554
|
-
t1 = blockMutations.updateContent();
|
|
555
|
-
$[1] = t1;
|
|
556
|
-
} else t1 = $[1];
|
|
557
|
-
const updateBlockContent = useMutation(t1);
|
|
558
|
-
let t2;
|
|
559
|
-
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
560
|
-
t2 = repeatableItemMutations.updateContent();
|
|
561
|
-
$[2] = t2;
|
|
562
|
-
} else t2 = $[2];
|
|
563
|
-
const updateRepeatableContent = useMutation(t2);
|
|
155
|
+
const Link = ({ name, children }) => {
|
|
156
|
+
const editingRuntime = useBlockEditingRuntime();
|
|
157
|
+
if (editingRuntime) return editingRuntime.renderPrimitive(options, "Link", {
|
|
158
|
+
name,
|
|
159
|
+
children
|
|
160
|
+
});
|
|
161
|
+
const value = normalizeLinkValue(useValue(name) ?? {});
|
|
564
162
|
const projectSlug = useProjectSlug();
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
t6 = {
|
|
582
|
-
...t4,
|
|
583
|
-
enabled: t5
|
|
584
|
-
};
|
|
585
|
-
$[7] = t4;
|
|
586
|
-
$[8] = t5;
|
|
587
|
-
$[9] = t6;
|
|
588
|
-
} else t6 = $[9];
|
|
589
|
-
const { data: pages } = useQuery(t6);
|
|
590
|
-
let t7;
|
|
591
|
-
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
592
|
-
t7 = { select: _temp };
|
|
593
|
-
$[10] = t7;
|
|
594
|
-
} else t7 = $[10];
|
|
595
|
-
const resolvedHref = resolveLinkHref(fieldValue, pages, useLocation(t7));
|
|
596
|
-
const fieldId = getOverlayFieldId(blockId, repeaterContext, String(name));
|
|
597
|
-
const [isEditing, setIsEditing] = React.useState(false);
|
|
598
|
-
const [displayText, setDisplayText] = React.useState(fieldValue.text);
|
|
599
|
-
const [isHovered, setIsHovered] = React.useState(false);
|
|
600
|
-
const [isEditorFocused, setIsEditorFocused] = React.useState(false);
|
|
601
|
-
const isSelectedFromSelection = useFieldSelection(blockId, String(name), "Link", repeaterContext?.itemId);
|
|
602
|
-
const isFocused = isEditorFocused || isSelectedFromSelection;
|
|
603
|
-
React.useEffect(() => {
|
|
604
|
-
if (!isEditing) setDisplayText(fieldValue.text);
|
|
605
|
-
}, [fieldValue.text, isEditing]);
|
|
606
|
-
const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", { fieldId });
|
|
607
|
-
let t8;
|
|
608
|
-
let t9;
|
|
609
|
-
if ($[11] !== isHoveredFromSidebar) {
|
|
610
|
-
t8 = () => {
|
|
611
|
-
setIsHovered(isHoveredFromSidebar);
|
|
612
|
-
};
|
|
613
|
-
t9 = [isHoveredFromSidebar];
|
|
614
|
-
$[11] = isHoveredFromSidebar;
|
|
615
|
-
$[12] = t8;
|
|
616
|
-
$[13] = t9;
|
|
617
|
-
} else {
|
|
618
|
-
t8 = $[12];
|
|
619
|
-
t9 = $[13];
|
|
620
|
-
}
|
|
621
|
-
React.useEffect(t8, t9);
|
|
622
|
-
let t10;
|
|
623
|
-
if ($[14] !== blockId || $[15] !== name || $[16] !== repeaterContext || $[17] !== updateBlockContent || $[18] !== updateRepeatableContent) {
|
|
624
|
-
t10 = (newLinkValue) => {
|
|
625
|
-
if (repeaterContext?.itemId != null) updateRepeatableContent.mutate({
|
|
626
|
-
id: repeaterContext.itemId,
|
|
627
|
-
content: { [name]: newLinkValue }
|
|
628
|
-
});
|
|
629
|
-
else updateBlockContent.mutate({
|
|
630
|
-
id: blockId,
|
|
631
|
-
content: { [name]: newLinkValue }
|
|
632
|
-
});
|
|
633
|
-
};
|
|
634
|
-
$[14] = blockId;
|
|
635
|
-
$[15] = name;
|
|
636
|
-
$[16] = repeaterContext;
|
|
637
|
-
$[17] = updateBlockContent;
|
|
638
|
-
$[18] = updateRepeatableContent;
|
|
639
|
-
$[19] = t10;
|
|
640
|
-
} else t10 = $[19];
|
|
641
|
-
const saveLinkValue = t10;
|
|
642
|
-
const handleInput = (e) => {
|
|
643
|
-
const newText = e.target.textContent || "";
|
|
644
|
-
saveLinkValue({
|
|
645
|
-
...fieldValue,
|
|
646
|
-
text: newText
|
|
647
|
-
});
|
|
648
|
-
};
|
|
649
|
-
let t11;
|
|
650
|
-
if ($[20] !== blockId || $[21] !== name || $[22] !== repeaterContext) {
|
|
651
|
-
t11 = () => {
|
|
652
|
-
setIsEditing(true);
|
|
653
|
-
setIsEditorFocused(true);
|
|
654
|
-
if (repeaterContext?.itemId != null) previewStore.send({
|
|
655
|
-
type: "selectItemField",
|
|
656
|
-
blockId,
|
|
657
|
-
itemId: repeaterContext.itemId,
|
|
658
|
-
fieldName: String(name),
|
|
659
|
-
fieldType: "Link"
|
|
660
|
-
});
|
|
661
|
-
else previewStore.send({
|
|
662
|
-
type: "selectBlockField",
|
|
663
|
-
blockId,
|
|
664
|
-
fieldName: String(name),
|
|
665
|
-
fieldType: "Link"
|
|
666
|
-
});
|
|
667
|
-
};
|
|
668
|
-
$[20] = blockId;
|
|
669
|
-
$[21] = name;
|
|
670
|
-
$[22] = repeaterContext;
|
|
671
|
-
$[23] = t11;
|
|
672
|
-
} else t11 = $[23];
|
|
673
|
-
const handleFocus = t11;
|
|
674
|
-
let t12;
|
|
675
|
-
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
676
|
-
t12 = () => {
|
|
677
|
-
setIsEditing(false);
|
|
678
|
-
setIsEditorFocused(false);
|
|
679
|
-
};
|
|
680
|
-
$[24] = t12;
|
|
681
|
-
} else t12 = $[24];
|
|
682
|
-
const handleBlur = t12;
|
|
683
|
-
let t13;
|
|
684
|
-
if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
|
|
685
|
-
t13 = (e_0) => {
|
|
686
|
-
e_0.stopPropagation();
|
|
687
|
-
previewStore.send({ type: "toggleContentSheet" });
|
|
688
|
-
setIsEditorFocused(false);
|
|
689
|
-
setIsEditing(false);
|
|
690
|
-
};
|
|
691
|
-
$[25] = t13;
|
|
692
|
-
} else t13 = $[25];
|
|
693
|
-
const handleEditLink = t13;
|
|
694
|
-
const linkData = {
|
|
695
|
-
text: displayText,
|
|
696
|
-
href: resolvedHref,
|
|
697
|
-
newTab: fieldValue.newTab
|
|
698
|
-
};
|
|
699
|
-
if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children({
|
|
700
|
-
to: resolvedHref,
|
|
701
|
-
target: fieldValue.newTab ? "_blank" : void 0,
|
|
702
|
-
rel: fieldValue.newTab ? "noreferrer" : void 0,
|
|
703
|
-
children: fieldValue.text
|
|
704
|
-
}, linkData) });
|
|
705
|
-
let t14;
|
|
706
|
-
let t15;
|
|
707
|
-
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
708
|
-
t14 = () => setIsHovered(true);
|
|
709
|
-
t15 = () => setIsHovered(false);
|
|
710
|
-
$[26] = t14;
|
|
711
|
-
$[27] = t15;
|
|
712
|
-
} else {
|
|
713
|
-
t14 = $[26];
|
|
714
|
-
t15 = $[27];
|
|
715
|
-
}
|
|
716
|
-
const linkProps = {
|
|
717
|
-
ref: elementRef,
|
|
718
|
-
to: resolvedHref,
|
|
719
|
-
target: fieldValue.newTab ? "_blank" : void 0,
|
|
720
|
-
rel: fieldValue.newTab ? "noreferrer" : void 0,
|
|
721
|
-
children: displayText,
|
|
722
|
-
"data-camox-field-id": fieldId,
|
|
723
|
-
"data-camox-hovered": isHovered || void 0,
|
|
724
|
-
"data-camox-focused": isFocused || void 0,
|
|
725
|
-
"data-camox-overlay-mode": mode === "layout" ? "layout" : void 0,
|
|
726
|
-
contentEditable: true,
|
|
727
|
-
onClick: _temp2,
|
|
728
|
-
onInput: handleInput,
|
|
729
|
-
onFocus: handleFocus,
|
|
730
|
-
onBlur: handleBlur,
|
|
731
|
-
onMouseEnter: t14,
|
|
732
|
-
onMouseLeave: t15,
|
|
733
|
-
onKeyDown: _temp3,
|
|
734
|
-
spellCheck: false,
|
|
735
|
-
suppressContentEditableWarning: true
|
|
736
|
-
};
|
|
737
|
-
const T0 = Popover;
|
|
738
|
-
const t16 = children(linkProps, linkData);
|
|
739
|
-
let t17;
|
|
740
|
-
if ($[28] !== handleEditLink) {
|
|
741
|
-
t17 = /* @__PURE__ */ jsx("button", {
|
|
742
|
-
type: "button",
|
|
743
|
-
className: "hover:bg-accent flex items-center gap-1.5 rounded-md px-2 py-1 text-sm transition-colors",
|
|
744
|
-
onMouseDown: _temp4,
|
|
745
|
-
onClick: handleEditLink,
|
|
746
|
-
children: "Edit link"
|
|
747
|
-
});
|
|
748
|
-
$[28] = handleEditLink;
|
|
749
|
-
$[29] = t17;
|
|
750
|
-
} else t17 = $[29];
|
|
751
|
-
let t18;
|
|
752
|
-
if ($[30] !== elementRef || $[31] !== t17) {
|
|
753
|
-
t18 = /* @__PURE__ */ jsx(PopoverContent, {
|
|
754
|
-
className: "w-auto p-2",
|
|
755
|
-
initialFocus: false,
|
|
756
|
-
anchor: elementRef,
|
|
757
|
-
align: "end",
|
|
758
|
-
children: t17
|
|
759
|
-
});
|
|
760
|
-
$[30] = elementRef;
|
|
761
|
-
$[31] = t17;
|
|
762
|
-
$[32] = t18;
|
|
763
|
-
} else t18 = $[32];
|
|
764
|
-
let t19;
|
|
765
|
-
if ($[33] !== T0 || $[34] !== isEditorFocused || $[35] !== t16 || $[36] !== t18) {
|
|
766
|
-
t19 = /* @__PURE__ */ jsxs(T0, {
|
|
767
|
-
open: isEditorFocused,
|
|
768
|
-
children: [t16, t18]
|
|
769
|
-
});
|
|
770
|
-
$[33] = T0;
|
|
771
|
-
$[34] = isEditorFocused;
|
|
772
|
-
$[35] = t16;
|
|
773
|
-
$[36] = t18;
|
|
774
|
-
$[37] = t19;
|
|
775
|
-
} else t19 = $[37];
|
|
776
|
-
return t19;
|
|
163
|
+
const { data: project } = useQuery(viewProjectQueries.getBySlug(projectSlug));
|
|
164
|
+
const { data: pages } = useQuery({
|
|
165
|
+
...viewPageQueries.list(project?.id ?? 0),
|
|
166
|
+
enabled: !!project
|
|
167
|
+
});
|
|
168
|
+
const href = resolveLinkHref(value, pages, useLocation({ select: (location) => location.pathname }));
|
|
169
|
+
return children({
|
|
170
|
+
to: href,
|
|
171
|
+
target: value.newTab ? "_blank" : void 0,
|
|
172
|
+
rel: value.newTab ? "noreferrer" : void 0,
|
|
173
|
+
children: value.text
|
|
174
|
+
}, {
|
|
175
|
+
text: value.text,
|
|
176
|
+
href,
|
|
177
|
+
newTab: value.newTab
|
|
178
|
+
});
|
|
777
179
|
};
|
|
778
|
-
|
|
779
|
-
const $ = c(
|
|
780
|
-
if ($[0] !== "
|
|
781
|
-
for (let $i = 0; $i <
|
|
782
|
-
$[0] = "
|
|
180
|
+
function useAsset(name) {
|
|
181
|
+
const $ = c(4);
|
|
182
|
+
if ($[0] !== "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982") {
|
|
183
|
+
for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
184
|
+
$[0] = "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982";
|
|
783
185
|
}
|
|
784
|
-
const
|
|
785
|
-
const
|
|
786
|
-
if (!blockContext) throw new Error("Image must be used within a Block Component");
|
|
787
|
-
const { blockId, content, mode } = blockContext;
|
|
788
|
-
const isContentEditable = useIsEditable(mode);
|
|
789
|
-
const { window: iframeWindow } = useFrame();
|
|
790
|
-
const repeaterContext = React.use(RepeaterItemContext);
|
|
186
|
+
const block = React.use(Context);
|
|
187
|
+
const item = React.use(RepeaterContext);
|
|
791
188
|
const { filesMap } = useNormalizedData();
|
|
792
|
-
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
};
|
|
815
|
-
t3 = [isHoveredFromSidebar];
|
|
816
|
-
$[3] = isHoveredFromSidebar;
|
|
817
|
-
$[4] = t2;
|
|
818
|
-
$[5] = t3;
|
|
819
|
-
} else {
|
|
820
|
-
t2 = $[4];
|
|
821
|
-
t3 = $[5];
|
|
822
|
-
}
|
|
823
|
-
React.useEffect(t2, t3);
|
|
824
|
-
let t4;
|
|
825
|
-
if ($[6] !== blockId || $[7] !== isContentEditable || $[8] !== overlayFieldName || $[9] !== overlayItemId) {
|
|
826
|
-
t4 = () => {
|
|
827
|
-
if (!isContentEditable) return;
|
|
828
|
-
if (overlayItemId != null) previewStore.send({
|
|
829
|
-
type: "selectItemField",
|
|
830
|
-
blockId,
|
|
831
|
-
itemId: overlayItemId,
|
|
832
|
-
fieldName: overlayFieldName,
|
|
833
|
-
fieldType: "Image"
|
|
834
|
-
});
|
|
835
|
-
else previewStore.send({
|
|
836
|
-
type: "selectBlockField",
|
|
837
|
-
blockId,
|
|
838
|
-
fieldName: overlayFieldName,
|
|
839
|
-
fieldType: "Image"
|
|
840
|
-
});
|
|
841
|
-
previewStore.send({ type: "toggleContentSheet" });
|
|
842
|
-
};
|
|
843
|
-
$[6] = blockId;
|
|
844
|
-
$[7] = isContentEditable;
|
|
845
|
-
$[8] = overlayFieldName;
|
|
846
|
-
$[9] = overlayItemId;
|
|
847
|
-
$[10] = t4;
|
|
848
|
-
} else t4 = $[10];
|
|
849
|
-
const handleClick = t4;
|
|
850
|
-
const imageProps = {
|
|
851
|
-
src: transformImageUrl(fieldValue.url, {
|
|
189
|
+
if (!block) throw new Error("Asset must be used within a Block Component");
|
|
190
|
+
const raw = item ? item.itemContent[name] : block.content[name];
|
|
191
|
+
let t0;
|
|
192
|
+
if ($[1] !== filesMap || $[2] !== raw) {
|
|
193
|
+
t0 = isFileMarker(raw) ? resolveFileMarker(raw, filesMap) : raw;
|
|
194
|
+
$[1] = filesMap;
|
|
195
|
+
$[2] = raw;
|
|
196
|
+
$[3] = t0;
|
|
197
|
+
} else t0 = $[3];
|
|
198
|
+
const resolved = t0;
|
|
199
|
+
const fallback = item ? repeatableDefaults[item.arrayFieldName]?.[String(name)] : contentDefaults[String(name)];
|
|
200
|
+
return resolved ?? fallback;
|
|
201
|
+
}
|
|
202
|
+
const Image = ({ name, children }) => {
|
|
203
|
+
const editingRuntime = useBlockEditingRuntime();
|
|
204
|
+
if (editingRuntime) return editingRuntime.renderPrimitive(options, "Image", {
|
|
205
|
+
name,
|
|
206
|
+
children
|
|
207
|
+
});
|
|
208
|
+
const value = useAsset(name);
|
|
209
|
+
return children({
|
|
210
|
+
src: transformImageUrl(value.url, {
|
|
852
211
|
width: getDefaultImageWidth(),
|
|
853
|
-
mimeType:
|
|
854
|
-
size:
|
|
212
|
+
mimeType: value.mimeType,
|
|
213
|
+
size: value.size
|
|
855
214
|
}),
|
|
856
|
-
srcSet: buildImageSrcSet(
|
|
215
|
+
srcSet: buildImageSrcSet(value.url, value.mimeType, value.size),
|
|
857
216
|
sizes: getDefaultImageSizes(),
|
|
858
|
-
alt:
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
const
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
217
|
+
alt: value.alt
|
|
218
|
+
}, value);
|
|
219
|
+
};
|
|
220
|
+
const File = ({ name, children }) => {
|
|
221
|
+
const editingRuntime = useBlockEditingRuntime();
|
|
222
|
+
if (editingRuntime) return editingRuntime.renderPrimitive(options, "File", {
|
|
223
|
+
name,
|
|
224
|
+
children
|
|
225
|
+
});
|
|
226
|
+
const value = useAsset(name);
|
|
227
|
+
return children({
|
|
228
|
+
href: value.url,
|
|
229
|
+
download: value.filename
|
|
230
|
+
}, value);
|
|
231
|
+
};
|
|
232
|
+
const AssetList = ({ name, children, primitive }) => {
|
|
233
|
+
const editingRuntime = useBlockEditingRuntime();
|
|
234
|
+
if (editingRuntime) return editingRuntime.renderPrimitive(options, primitive, {
|
|
235
|
+
name,
|
|
236
|
+
children
|
|
237
|
+
});
|
|
238
|
+
const block = React.use(Context);
|
|
239
|
+
const parent = React.use(RepeaterContext);
|
|
240
|
+
const { filesMap } = useNormalizedData();
|
|
241
|
+
if (!block) throw new Error("ImageList/FileList must be used within a Block Component");
|
|
242
|
+
const fieldName = String(name);
|
|
243
|
+
const schema = parent ? typeboxSchema.properties[parent.arrayFieldName]?.items?.properties?.[fieldName] : typeboxSchema.properties[fieldName];
|
|
244
|
+
const fieldType = schema?.fieldType;
|
|
245
|
+
if (fieldType !== "ImageList" && fieldType !== "FileList") throw new Error(`"${fieldName}" is not a Type.ImageList or Type.FileList field`);
|
|
246
|
+
const source = parent ? parent.itemContent[fieldName] : block.content[fieldName];
|
|
247
|
+
let values = Array.isArray(source) ? source : [];
|
|
248
|
+
if (values.length === 0 && schema.defaultItems > 0 && schema.items?.default) values = Array.from({ length: schema.defaultItems }, () => schema.items.default);
|
|
249
|
+
const Single = fieldType === "ImageList" ? Image : File;
|
|
250
|
+
return values.map((value) => isFileMarker(value) ? resolveFileMarker(value, filesMap) : value).filter(Boolean).map((value_0, index) => /* @__PURE__ */ jsx(RepeaterContext.Provider, {
|
|
251
|
+
value: {
|
|
252
|
+
arrayFieldName: fieldName,
|
|
253
|
+
containerItemId: parent?.itemId ?? parent?.containerItemId,
|
|
254
|
+
itemContent: { [ASSET_LIST_SELF_KEY]: value_0 },
|
|
255
|
+
itemSettings: {}
|
|
256
|
+
},
|
|
257
|
+
children: /* @__PURE__ */ jsx(Single, {
|
|
258
|
+
name: ASSET_LIST_SELF_KEY,
|
|
259
|
+
children
|
|
260
|
+
})
|
|
261
|
+
}, index));
|
|
262
|
+
};
|
|
263
|
+
const ImageList = (props) => {
|
|
264
|
+
const $ = c(3);
|
|
265
|
+
if ($[0] !== "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982") {
|
|
266
|
+
for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
267
|
+
$[0] = "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982";
|
|
875
268
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
"
|
|
881
|
-
"data-camox-field-type": t5,
|
|
882
|
-
"data-camox-hovered": t6,
|
|
883
|
-
"data-camox-focused": t7,
|
|
884
|
-
"data-camox-overlay-mode": t8,
|
|
885
|
-
onMouseEnter: t9,
|
|
886
|
-
onMouseLeave: t10,
|
|
887
|
-
onClick: handleClick,
|
|
888
|
-
children: t11
|
|
269
|
+
let t0;
|
|
270
|
+
if ($[1] !== props) {
|
|
271
|
+
t0 = /* @__PURE__ */ jsx(AssetList, {
|
|
272
|
+
...props,
|
|
273
|
+
primitive: "ImageList"
|
|
889
274
|
});
|
|
890
|
-
$[
|
|
891
|
-
$[
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
$[17] = t6;
|
|
895
|
-
$[18] = t7;
|
|
896
|
-
$[19] = t8;
|
|
897
|
-
$[20] = t9;
|
|
898
|
-
$[21] = t12;
|
|
899
|
-
} else t12 = $[21];
|
|
900
|
-
return t12;
|
|
275
|
+
$[1] = props;
|
|
276
|
+
$[2] = t0;
|
|
277
|
+
} else t0 = $[2];
|
|
278
|
+
return t0;
|
|
901
279
|
};
|
|
902
|
-
const
|
|
903
|
-
const $ = c(
|
|
904
|
-
if ($[0] !== "
|
|
905
|
-
for (let $i = 0; $i <
|
|
906
|
-
$[0] = "
|
|
280
|
+
const FileList = (props) => {
|
|
281
|
+
const $ = c(3);
|
|
282
|
+
if ($[0] !== "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982") {
|
|
283
|
+
for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
284
|
+
$[0] = "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982";
|
|
907
285
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
const defaultValue = repeaterContext ? repeatableItemDefaults[repeaterContext.arrayFieldName]?.[String(name)] : contentDefaults[String(name)];
|
|
919
|
-
const fieldValue = rawValue ?? defaultValue;
|
|
920
|
-
t1 = children({
|
|
921
|
-
href: fieldValue.url,
|
|
922
|
-
download: fieldValue.filename
|
|
923
|
-
}, fieldValue);
|
|
924
|
-
$[1] = children;
|
|
925
|
-
$[2] = filesMap;
|
|
926
|
-
$[3] = name;
|
|
927
|
-
$[4] = rawSource;
|
|
928
|
-
$[5] = repeaterContext;
|
|
929
|
-
$[6] = t1;
|
|
930
|
-
} else t1 = $[6];
|
|
931
|
-
let t2;
|
|
932
|
-
if ($[7] !== t1) {
|
|
933
|
-
t2 = /* @__PURE__ */ jsx(Fragment, { children: t1 });
|
|
934
|
-
$[7] = t1;
|
|
935
|
-
$[8] = t2;
|
|
936
|
-
} else t2 = $[8];
|
|
937
|
-
return t2;
|
|
286
|
+
let t0;
|
|
287
|
+
if ($[1] !== props) {
|
|
288
|
+
t0 = /* @__PURE__ */ jsx(AssetList, {
|
|
289
|
+
...props,
|
|
290
|
+
primitive: "FileList"
|
|
291
|
+
});
|
|
292
|
+
$[1] = props;
|
|
293
|
+
$[2] = t0;
|
|
294
|
+
} else t0 = $[2];
|
|
295
|
+
return t0;
|
|
938
296
|
};
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
297
|
+
const Repeater = ({ name, children }) => {
|
|
298
|
+
const editingRuntime = useBlockEditingRuntime();
|
|
299
|
+
if (editingRuntime) return editingRuntime.renderPrimitive(options, "Repeater", {
|
|
300
|
+
name,
|
|
301
|
+
children
|
|
302
|
+
});
|
|
303
|
+
const block = React.use(Context);
|
|
304
|
+
const parent = React.use(RepeaterContext);
|
|
305
|
+
const { itemsMap } = useNormalizedData();
|
|
306
|
+
if (!block) throw new Error("Repeater must be used within a Block Component");
|
|
945
307
|
const fieldName = String(name);
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
308
|
+
const source = parent ? parent.itemContent[fieldName] : block.content[fieldName];
|
|
309
|
+
if (!Array.isArray(source)) throw new Error(`Field "${fieldName}" is not an array`);
|
|
310
|
+
return source.map((item) => isItemMarker(item) ? itemsMap.get(item._itemId) ?? null : item).filter(Boolean).map((item_0, index) => {
|
|
311
|
+
const databaseItem = item_0.content !== void 0 && item_0.id != null;
|
|
312
|
+
const itemContent = {
|
|
313
|
+
...repeatableDefaults[fieldName],
|
|
314
|
+
...databaseItem ? item_0.content : item_0
|
|
315
|
+
};
|
|
316
|
+
const itemSettings = {
|
|
317
|
+
...repeatableSettingsDefaults[fieldName],
|
|
318
|
+
...databaseItem ? item_0.settings : null
|
|
319
|
+
};
|
|
320
|
+
const itemId = databaseItem ? item_0.id : void 0;
|
|
321
|
+
const api = {
|
|
322
|
+
Field,
|
|
323
|
+
Link,
|
|
324
|
+
Embed,
|
|
325
|
+
Image,
|
|
326
|
+
File,
|
|
327
|
+
ImageList,
|
|
328
|
+
FileList,
|
|
329
|
+
Repeater,
|
|
330
|
+
useSetting: (settingName) => itemSettings[settingName]
|
|
331
|
+
};
|
|
332
|
+
return /* @__PURE__ */ jsx(RepeaterContext.Provider, {
|
|
962
333
|
value: {
|
|
963
334
|
arrayFieldName: fieldName,
|
|
964
|
-
|
|
965
|
-
itemContent
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
containerItemId: parentRepeaterContext?.itemId ?? parentRepeaterContext?.containerItemId
|
|
335
|
+
containerItemId: itemId ?? parent?.containerItemId,
|
|
336
|
+
itemContent,
|
|
337
|
+
itemId,
|
|
338
|
+
itemSettings
|
|
969
339
|
},
|
|
970
|
-
children:
|
|
971
|
-
|
|
972
|
-
children
|
|
973
|
-
})
|
|
974
|
-
}, index))
|
|
340
|
+
children: children(api, index)
|
|
341
|
+
}, itemId ?? index);
|
|
975
342
|
});
|
|
976
343
|
};
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
983
|
-
$[0] = "9cd21990f1cb26b8613f764719b3c2aa84ab101438380ec49833d48adbdfe407";
|
|
344
|
+
const useSetting = (name) => {
|
|
345
|
+
const $ = c(4);
|
|
346
|
+
if ($[0] !== "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982") {
|
|
347
|
+
for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
348
|
+
$[0] = "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982";
|
|
984
349
|
}
|
|
985
|
-
const
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
itemId: t2
|
|
996
|
-
};
|
|
997
|
-
$[1] = t1;
|
|
998
|
-
$[2] = t2;
|
|
999
|
-
$[3] = t3;
|
|
1000
|
-
} else t3 = $[3];
|
|
1001
|
-
const isHovered = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATER_ITEM", "CAMOX_HOVER_REPEATER_ITEM_END", t3);
|
|
1002
|
-
const showOverlay = isContentEditable && (isHovered || isRepeaterHovered);
|
|
1003
|
-
const t4 = isContentEditable ? itemId : void 0;
|
|
1004
|
-
const t5 = showOverlay || void 0;
|
|
1005
|
-
const t6 = mode === "layout" ? "layout" : void 0;
|
|
1006
|
-
let t7;
|
|
1007
|
-
if ($[4] !== children || $[5] !== t4 || $[6] !== t5 || $[7] !== t6) {
|
|
1008
|
-
t7 = /* @__PURE__ */ jsx("div", {
|
|
1009
|
-
"data-camox-repeater-item-id": t4,
|
|
1010
|
-
"data-camox-hovered": t5,
|
|
1011
|
-
"data-camox-overlay-mode": t6,
|
|
1012
|
-
children
|
|
1013
|
-
});
|
|
1014
|
-
$[4] = children;
|
|
1015
|
-
$[5] = t4;
|
|
1016
|
-
$[6] = t5;
|
|
1017
|
-
$[7] = t6;
|
|
1018
|
-
$[8] = t7;
|
|
1019
|
-
} else t7 = $[8];
|
|
1020
|
-
return t7;
|
|
1021
|
-
};
|
|
1022
|
-
const RepeaterHoverProvider = (t0) => {
|
|
1023
|
-
const $ = c(7);
|
|
1024
|
-
if ($[0] !== "9cd21990f1cb26b8613f764719b3c2aa84ab101438380ec49833d48adbdfe407") {
|
|
1025
|
-
for (let $i = 0; $i < 7; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
1026
|
-
$[0] = "9cd21990f1cb26b8613f764719b3c2aa84ab101438380ec49833d48adbdfe407";
|
|
350
|
+
const editingRuntime = useBlockEditingRuntime();
|
|
351
|
+
if (editingRuntime) {
|
|
352
|
+
let t0;
|
|
353
|
+
if ($[1] !== editingRuntime || $[2] !== name) {
|
|
354
|
+
t0 = editingRuntime.getSetting(options, name);
|
|
355
|
+
$[1] = editingRuntime;
|
|
356
|
+
$[2] = name;
|
|
357
|
+
$[3] = t0;
|
|
358
|
+
} else t0 = $[3];
|
|
359
|
+
return t0;
|
|
1027
360
|
}
|
|
1028
|
-
const
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
const t1 = String(blockId);
|
|
1032
|
-
let t2;
|
|
1033
|
-
if ($[1] !== fieldName || $[2] !== t1) {
|
|
1034
|
-
t2 = {
|
|
1035
|
-
blockId: t1,
|
|
1036
|
-
fieldName
|
|
1037
|
-
};
|
|
1038
|
-
$[1] = fieldName;
|
|
1039
|
-
$[2] = t1;
|
|
1040
|
-
$[3] = t2;
|
|
1041
|
-
} else t2 = $[3];
|
|
1042
|
-
const isHovered = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATER", "CAMOX_HOVER_REPEATER_END", t2);
|
|
1043
|
-
let t3;
|
|
1044
|
-
if ($[4] !== children || $[5] !== isHovered) {
|
|
1045
|
-
t3 = /* @__PURE__ */ jsx(RepeaterHoverContext.Provider, {
|
|
1046
|
-
value: isHovered,
|
|
1047
|
-
children
|
|
1048
|
-
});
|
|
1049
|
-
$[4] = children;
|
|
1050
|
-
$[5] = isHovered;
|
|
1051
|
-
$[6] = t3;
|
|
1052
|
-
} else t3 = $[6];
|
|
1053
|
-
return t3;
|
|
361
|
+
const context = React.use(Context);
|
|
362
|
+
if (!context) throw new Error("useSetting must be used within a Block Component");
|
|
363
|
+
return context.settings[name];
|
|
1054
364
|
};
|
|
1055
|
-
const
|
|
1056
|
-
const $ = c(
|
|
1057
|
-
if ($[0] !== "
|
|
1058
|
-
for (let $i = 0; $i <
|
|
1059
|
-
$[0] = "
|
|
365
|
+
const Detached = (t0) => {
|
|
366
|
+
const $ = c(6);
|
|
367
|
+
if ($[0] !== "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982") {
|
|
368
|
+
for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
369
|
+
$[0] = "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982";
|
|
1060
370
|
}
|
|
1061
|
-
const {
|
|
1062
|
-
const
|
|
1063
|
-
if (
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
const ItemFileList = _AssetList;
|
|
1073
|
-
const ItemFile = File;
|
|
1074
|
-
const ItemRepeater = Repeater;
|
|
1075
|
-
const source = parentRepeaterContext ? parentRepeaterContext.itemContent[name] : content[name];
|
|
1076
|
-
const { itemsMap } = useNormalizedData();
|
|
1077
|
-
let T0;
|
|
1078
|
-
let t1;
|
|
1079
|
-
let t2;
|
|
1080
|
-
let t3;
|
|
1081
|
-
if ($[1] !== blockId || $[2] !== children || $[3] !== fieldName || $[4] !== itemsMap || $[5] !== mode || $[6] !== name || $[7] !== parentRepeaterContext?.containerItemId || $[8] !== source) {
|
|
1082
|
-
let arrayValue = source ?? [];
|
|
1083
|
-
if (!Array.isArray(arrayValue)) throw new Error(`Field "${String(name)}" is not an array`);
|
|
1084
|
-
let t4;
|
|
1085
|
-
if ($[13] !== itemsMap) {
|
|
1086
|
-
t4 = (item) => {
|
|
1087
|
-
if (isItemMarker(item)) return itemsMap.get(item._itemId) ?? null;
|
|
1088
|
-
return item;
|
|
1089
|
-
};
|
|
1090
|
-
$[13] = itemsMap;
|
|
1091
|
-
$[14] = t4;
|
|
1092
|
-
} else t4 = $[14];
|
|
1093
|
-
arrayValue = arrayValue.map(t4).filter(Boolean);
|
|
1094
|
-
const settingsDefaultsForField = repeatableItemSettingsDefaults[fieldName];
|
|
1095
|
-
T0 = RepeaterHoverProvider;
|
|
1096
|
-
t1 = blockId;
|
|
1097
|
-
t2 = fieldName;
|
|
1098
|
-
let t5;
|
|
1099
|
-
if ($[15] !== blockId || $[16] !== children || $[17] !== fieldName || $[18] !== mode || $[19] !== parentRepeaterContext?.containerItemId || $[20] !== settingsDefaultsForField) {
|
|
1100
|
-
t5 = (item_0, index) => {
|
|
1101
|
-
const isDbItem = item_0.content !== void 0 && item_0.id != null;
|
|
1102
|
-
const itemContent = {
|
|
1103
|
-
...repeatableItemDefaults[fieldName],
|
|
1104
|
-
...isDbItem ? item_0.content : item_0
|
|
1105
|
-
};
|
|
1106
|
-
const itemSettings = {
|
|
1107
|
-
...settingsDefaultsForField,
|
|
1108
|
-
...isDbItem ? item_0.settings : null
|
|
1109
|
-
};
|
|
1110
|
-
const itemId = isDbItem ? item_0.id : void 0;
|
|
1111
|
-
const useItemSetting = (settingName) => itemSettings[settingName];
|
|
1112
|
-
const itemApi = {
|
|
1113
|
-
Field: ItemField,
|
|
1114
|
-
Link: ItemLink,
|
|
1115
|
-
Embed: ItemEmbed,
|
|
1116
|
-
Image: ItemImage,
|
|
1117
|
-
File: ItemFile,
|
|
1118
|
-
ImageList: ItemImageList,
|
|
1119
|
-
FileList: ItemFileList,
|
|
1120
|
-
Repeater: ItemRepeater,
|
|
1121
|
-
useSetting: useItemSetting
|
|
1122
|
-
};
|
|
1123
|
-
return /* @__PURE__ */ jsx(RepeaterItemContext.Provider, {
|
|
1124
|
-
value: {
|
|
1125
|
-
arrayFieldName: fieldName,
|
|
1126
|
-
itemIndex: index,
|
|
1127
|
-
itemContent,
|
|
1128
|
-
itemSettings,
|
|
1129
|
-
itemId,
|
|
1130
|
-
containerItemId: itemId ?? parentRepeaterContext?.containerItemId
|
|
1131
|
-
},
|
|
1132
|
-
children: /* @__PURE__ */ jsx(RepeaterItemWrapper, {
|
|
1133
|
-
itemId,
|
|
1134
|
-
blockId,
|
|
1135
|
-
mode,
|
|
1136
|
-
children: children(itemApi, index)
|
|
1137
|
-
})
|
|
1138
|
-
}, itemId ?? index);
|
|
1139
|
-
};
|
|
1140
|
-
$[15] = blockId;
|
|
1141
|
-
$[16] = children;
|
|
1142
|
-
$[17] = fieldName;
|
|
1143
|
-
$[18] = mode;
|
|
1144
|
-
$[19] = parentRepeaterContext?.containerItemId;
|
|
1145
|
-
$[20] = settingsDefaultsForField;
|
|
1146
|
-
$[21] = t5;
|
|
1147
|
-
} else t5 = $[21];
|
|
1148
|
-
t3 = arrayValue.map(t5);
|
|
1149
|
-
$[1] = blockId;
|
|
1150
|
-
$[2] = children;
|
|
1151
|
-
$[3] = fieldName;
|
|
1152
|
-
$[4] = itemsMap;
|
|
1153
|
-
$[5] = mode;
|
|
1154
|
-
$[6] = name;
|
|
1155
|
-
$[7] = parentRepeaterContext?.containerItemId;
|
|
1156
|
-
$[8] = source;
|
|
1157
|
-
$[9] = T0;
|
|
1158
|
-
$[10] = t1;
|
|
1159
|
-
$[11] = t2;
|
|
1160
|
-
$[12] = t3;
|
|
1161
|
-
} else {
|
|
1162
|
-
T0 = $[9];
|
|
1163
|
-
t1 = $[10];
|
|
1164
|
-
t2 = $[11];
|
|
1165
|
-
t3 = $[12];
|
|
371
|
+
const { children } = t0;
|
|
372
|
+
const editingRuntime = useBlockEditingRuntime();
|
|
373
|
+
if (editingRuntime) {
|
|
374
|
+
let t1;
|
|
375
|
+
if ($[1] !== children || $[2] !== editingRuntime) {
|
|
376
|
+
t1 = editingRuntime.renderPrimitive(options, "Detached", { children });
|
|
377
|
+
$[1] = children;
|
|
378
|
+
$[2] = editingRuntime;
|
|
379
|
+
$[3] = t1;
|
|
380
|
+
} else t1 = $[3];
|
|
381
|
+
return t1;
|
|
1166
382
|
}
|
|
1167
|
-
let
|
|
1168
|
-
if ($[
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
383
|
+
let t1;
|
|
384
|
+
if ($[4] !== children) {
|
|
385
|
+
t1 = children({
|
|
386
|
+
ref: _temp,
|
|
387
|
+
style: { opacity: 1 },
|
|
388
|
+
onClick: _temp2,
|
|
389
|
+
onMouseEnter: _temp3,
|
|
390
|
+
onMouseLeave: _temp4
|
|
1173
391
|
});
|
|
1174
|
-
$[
|
|
1175
|
-
$[
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
$[26] = t4;
|
|
1179
|
-
} else t4 = $[26];
|
|
1180
|
-
return t4;
|
|
392
|
+
$[4] = children;
|
|
393
|
+
$[5] = t1;
|
|
394
|
+
} else t1 = $[5];
|
|
395
|
+
return t1;
|
|
1181
396
|
};
|
|
1182
|
-
const
|
|
1183
|
-
const $ = c(
|
|
1184
|
-
if ($[0] !== "
|
|
1185
|
-
for (let $i = 0; $i <
|
|
1186
|
-
$[0] = "
|
|
397
|
+
const Component = (props) => {
|
|
398
|
+
const $ = c(23);
|
|
399
|
+
if ($[0] !== "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982") {
|
|
400
|
+
for (let $i = 0; $i < 23; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
401
|
+
$[0] = "04a637ebd823abadf975e738c0e326acccffcffd1f7360db558a19fce0075982";
|
|
1187
402
|
}
|
|
1188
|
-
const
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
const [isFirstRender, setIsFirstRender] = React.useState(true);
|
|
1199
|
-
let t1;
|
|
1200
|
-
let t2;
|
|
1201
|
-
if ($[1] !== isFirstRender) {
|
|
1202
|
-
t1 = () => {
|
|
1203
|
-
if (isFirstRender) setIsFirstRender(false);
|
|
1204
|
-
};
|
|
1205
|
-
t2 = [isFirstRender];
|
|
1206
|
-
$[1] = isFirstRender;
|
|
1207
|
-
$[2] = t1;
|
|
1208
|
-
$[3] = t2;
|
|
1209
|
-
} else {
|
|
1210
|
-
t1 = $[2];
|
|
1211
|
-
t2 = $[3];
|
|
403
|
+
const editingRuntime = useBlockEditingRuntime();
|
|
404
|
+
if (editingRuntime) {
|
|
405
|
+
let t0;
|
|
406
|
+
if ($[1] !== editingRuntime || $[2] !== props) {
|
|
407
|
+
t0 = editingRuntime.renderBlock(options, props);
|
|
408
|
+
$[1] = editingRuntime;
|
|
409
|
+
$[2] = props;
|
|
410
|
+
$[3] = t0;
|
|
411
|
+
} else t0 = $[3];
|
|
412
|
+
return t0;
|
|
1212
413
|
}
|
|
1213
|
-
|
|
1214
|
-
let
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
behavior: isFirstRender ? "instant" : "smooth",
|
|
1221
|
-
block: isFirstRender ? "start" : "nearest"
|
|
1222
|
-
});
|
|
1223
|
-
};
|
|
1224
|
-
$[4] = blockData._id;
|
|
1225
|
-
$[5] = isBlockSelected;
|
|
1226
|
-
$[6] = isFirstRender;
|
|
1227
|
-
$[7] = pendingAgentBlockFocus?.blockId;
|
|
1228
|
-
$[8] = t3;
|
|
1229
|
-
} else t3 = $[8];
|
|
1230
|
-
let t4;
|
|
1231
|
-
if ($[9] !== blockData._id || $[10] !== isBlockSelected || $[11] !== isFirstRender || $[12] !== isPageEditorSidebarOpen || $[13] !== pendingAgentBlockFocus) {
|
|
1232
|
-
t4 = [
|
|
1233
|
-
blockData._id,
|
|
1234
|
-
isBlockSelected,
|
|
1235
|
-
isFirstRender,
|
|
1236
|
-
isPageEditorSidebarOpen,
|
|
1237
|
-
pendingAgentBlockFocus
|
|
1238
|
-
];
|
|
1239
|
-
$[9] = blockData._id;
|
|
1240
|
-
$[10] = isBlockSelected;
|
|
1241
|
-
$[11] = isFirstRender;
|
|
1242
|
-
$[12] = isPageEditorSidebarOpen;
|
|
1243
|
-
$[13] = pendingAgentBlockFocus;
|
|
1244
|
-
$[14] = t4;
|
|
1245
|
-
} else t4 = $[14];
|
|
1246
|
-
React.useEffect(t3, t4);
|
|
1247
|
-
let t5;
|
|
1248
|
-
let t6;
|
|
1249
|
-
if ($[15] !== blockData._id || $[16] !== pendingAgentBlockFocus) {
|
|
1250
|
-
t5 = () => {
|
|
1251
|
-
if (!pendingAgentBlockFocus || pendingAgentBlockFocus.blockId !== blockData._id) return;
|
|
1252
|
-
if (!ref.current) return;
|
|
1253
|
-
ref.current.scrollIntoView({
|
|
1254
|
-
behavior: "smooth",
|
|
1255
|
-
block: "nearest"
|
|
1256
|
-
});
|
|
1257
|
-
previewStore.send({
|
|
1258
|
-
type: "clearPendingAgentBlockFocus",
|
|
1259
|
-
requestId: pendingAgentBlockFocus.requestId
|
|
1260
|
-
});
|
|
1261
|
-
};
|
|
1262
|
-
t6 = [blockData._id, pendingAgentBlockFocus];
|
|
1263
|
-
$[15] = blockData._id;
|
|
1264
|
-
$[16] = pendingAgentBlockFocus;
|
|
1265
|
-
$[17] = t5;
|
|
1266
|
-
$[18] = t6;
|
|
1267
|
-
} else {
|
|
1268
|
-
t5 = $[17];
|
|
1269
|
-
t6 = $[18];
|
|
1270
|
-
}
|
|
1271
|
-
React.useEffect(t5, t6);
|
|
1272
|
-
const t7 = String(blockData._id);
|
|
1273
|
-
let t8;
|
|
1274
|
-
if ($[19] !== t7) {
|
|
1275
|
-
t8 = { blockId: t7 };
|
|
1276
|
-
$[19] = t7;
|
|
1277
|
-
$[20] = t8;
|
|
1278
|
-
} else t8 = $[20];
|
|
1279
|
-
const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_BLOCK", "CAMOX_HOVER_BLOCK_END", t8);
|
|
1280
|
-
let t10;
|
|
1281
|
-
let t9;
|
|
1282
|
-
if ($[21] !== isHoveredFromSidebar) {
|
|
1283
|
-
t9 = () => {
|
|
1284
|
-
setIsHovered(isHoveredFromSidebar);
|
|
414
|
+
const { blockData, mode } = props;
|
|
415
|
+
let mergedContent;
|
|
416
|
+
let normalizedContent;
|
|
417
|
+
if ($[4] !== blockData.content) {
|
|
418
|
+
mergedContent = {
|
|
419
|
+
...contentDefaults,
|
|
420
|
+
...blockData.content
|
|
1285
421
|
};
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
$[
|
|
1289
|
-
$[
|
|
422
|
+
normalizedContent = { ...mergedContent };
|
|
423
|
+
for (const [key, value] of Object.entries(normalizedContent)) if (Array.isArray(value) && value[0]?.content !== void 0) normalizedContent[key] = value.map(_temp5);
|
|
424
|
+
$[4] = blockData.content;
|
|
425
|
+
$[5] = mergedContent;
|
|
426
|
+
$[6] = normalizedContent;
|
|
1290
427
|
} else {
|
|
1291
|
-
|
|
1292
|
-
|
|
428
|
+
mergedContent = $[5];
|
|
429
|
+
normalizedContent = $[6];
|
|
1293
430
|
}
|
|
1294
|
-
|
|
1295
|
-
let
|
|
1296
|
-
if ($[
|
|
1297
|
-
|
|
1298
|
-
for (const key in result) {
|
|
1299
|
-
const value = result[key];
|
|
1300
|
-
if (Array.isArray(value) && value.length > 0 && value[0]?.content !== void 0) result[key] = value.map(_temp9);
|
|
1301
|
-
}
|
|
1302
|
-
$[24] = blockData.content;
|
|
1303
|
-
$[25] = result;
|
|
1304
|
-
} else result = $[25];
|
|
1305
|
-
const normalizedContent = result;
|
|
1306
|
-
let t11;
|
|
1307
|
-
if ($[26] !== blockData._id || $[27] !== isContentEditable) {
|
|
1308
|
-
t11 = (e) => {
|
|
1309
|
-
if (!isContentEditable) return;
|
|
1310
|
-
if (e.target.closest("[data-camox-field-id]")) return;
|
|
1311
|
-
previewStore.send({
|
|
1312
|
-
type: "setFocusedBlock",
|
|
1313
|
-
blockId: blockData._id
|
|
1314
|
-
});
|
|
1315
|
-
};
|
|
1316
|
-
$[26] = blockData._id;
|
|
1317
|
-
$[27] = isContentEditable;
|
|
1318
|
-
$[28] = t11;
|
|
1319
|
-
} else t11 = $[28];
|
|
1320
|
-
const handleClick = t11;
|
|
1321
|
-
let t12;
|
|
1322
|
-
if ($[29] !== isContentEditable) {
|
|
1323
|
-
t12 = () => {
|
|
1324
|
-
if (isContentEditable) setIsHovered(true);
|
|
1325
|
-
};
|
|
1326
|
-
$[29] = isContentEditable;
|
|
1327
|
-
$[30] = t12;
|
|
1328
|
-
} else t12 = $[30];
|
|
1329
|
-
const handleMouseEnter = t12;
|
|
1330
|
-
let t13;
|
|
1331
|
-
if ($[31] !== isContentEditable) {
|
|
1332
|
-
t13 = () => {
|
|
1333
|
-
if (isContentEditable) setIsHovered(false);
|
|
1334
|
-
};
|
|
1335
|
-
$[31] = isContentEditable;
|
|
1336
|
-
$[32] = t13;
|
|
1337
|
-
} else t13 = $[32];
|
|
1338
|
-
const handleMouseLeave = t13;
|
|
1339
|
-
let t14;
|
|
1340
|
-
if ($[33] !== addBlockAfterPosition || $[34] !== blockData.position) {
|
|
1341
|
-
t14 = (insertPosition) => {
|
|
1342
|
-
postOverlayMessage({
|
|
1343
|
-
type: "CAMOX_ADD_BLOCK_REQUEST",
|
|
1344
|
-
blockPosition: blockData.position,
|
|
1345
|
-
insertPosition,
|
|
1346
|
-
...addBlockAfterPosition !== void 0 && { afterPosition: addBlockAfterPosition }
|
|
1347
|
-
});
|
|
1348
|
-
};
|
|
1349
|
-
$[33] = addBlockAfterPosition;
|
|
1350
|
-
$[34] = blockData.position;
|
|
1351
|
-
$[35] = t14;
|
|
1352
|
-
} else t14 = $[35];
|
|
1353
|
-
const handleAddBlockClick = t14;
|
|
1354
|
-
const shouldShowOverlay = isContentEditable && (isHovered || isBlockSelected) && !isAddBlockSidebarOpen;
|
|
1355
|
-
const shouldShowAddBlockOverlay = isAddBlockSidebarOpen && mode !== "peek";
|
|
1356
|
-
let t15;
|
|
1357
|
-
if ($[36] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1358
|
-
t15 = {
|
|
431
|
+
const AuthoredComponent = options.component;
|
|
432
|
+
let t0;
|
|
433
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
434
|
+
t0 = {
|
|
1359
435
|
position: "relative",
|
|
1360
436
|
scrollMargin: "5rem",
|
|
1361
437
|
background: "var(--background)"
|
|
1362
438
|
};
|
|
1363
|
-
$[
|
|
1364
|
-
} else
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
const t19 = mode === "layout" ? "layout" : void 0;
|
|
1369
|
-
const t20 = blockData._id;
|
|
1370
|
-
let t21;
|
|
1371
|
-
if ($[37] !== blockData.content) {
|
|
1372
|
-
t21 = {
|
|
1373
|
-
...contentDefaults,
|
|
1374
|
-
...blockData.content
|
|
1375
|
-
};
|
|
1376
|
-
$[37] = blockData.content;
|
|
1377
|
-
$[38] = t21;
|
|
1378
|
-
} else t21 = $[38];
|
|
1379
|
-
const merged = t21;
|
|
1380
|
-
let overrides;
|
|
1381
|
-
if ($[39] !== merged) {
|
|
1382
|
-
overrides = {};
|
|
1383
|
-
for (const key_0 in merged) {
|
|
1384
|
-
const val = merged[key_0];
|
|
1385
|
-
if (val && typeof val === "object" && "url" in val && !val.url && contentDefaults[key_0]) overrides[key_0] = contentDefaults[key_0];
|
|
1386
|
-
}
|
|
1387
|
-
$[39] = merged;
|
|
1388
|
-
$[40] = overrides;
|
|
1389
|
-
} else overrides = $[40];
|
|
1390
|
-
let t22;
|
|
1391
|
-
if ($[41] !== merged || $[42] !== overrides) {
|
|
1392
|
-
t22 = {
|
|
1393
|
-
...merged,
|
|
1394
|
-
...overrides
|
|
1395
|
-
};
|
|
1396
|
-
$[41] = merged;
|
|
1397
|
-
$[42] = overrides;
|
|
1398
|
-
$[43] = t22;
|
|
1399
|
-
} else t22 = $[43];
|
|
1400
|
-
const t23 = t22;
|
|
1401
|
-
let t24;
|
|
1402
|
-
if ($[44] !== blockData.settings) {
|
|
1403
|
-
t24 = {
|
|
439
|
+
$[7] = t0;
|
|
440
|
+
} else t0 = $[7];
|
|
441
|
+
let t1;
|
|
442
|
+
if ($[8] !== blockData.settings) {
|
|
443
|
+
t1 = {
|
|
1404
444
|
...settingsDefaults,
|
|
1405
445
|
...blockData.settings
|
|
1406
446
|
};
|
|
1407
|
-
$[
|
|
1408
|
-
$[
|
|
1409
|
-
} else
|
|
1410
|
-
const t25 = t24;
|
|
1411
|
-
let t26;
|
|
1412
|
-
if ($[46] !== blockData._id || $[47] !== isHovered || $[48] !== mode || $[49] !== t23 || $[50] !== t25) {
|
|
1413
|
-
t26 = {
|
|
1414
|
-
blockId: t20,
|
|
1415
|
-
content: t23,
|
|
1416
|
-
settings: t25,
|
|
1417
|
-
mode,
|
|
1418
|
-
isHovered,
|
|
1419
|
-
setIsHovered
|
|
1420
|
-
};
|
|
1421
|
-
$[46] = blockData._id;
|
|
1422
|
-
$[47] = isHovered;
|
|
1423
|
-
$[48] = mode;
|
|
1424
|
-
$[49] = t23;
|
|
1425
|
-
$[50] = t25;
|
|
1426
|
-
$[51] = t26;
|
|
1427
|
-
} else t26 = $[51];
|
|
1428
|
-
let t27;
|
|
1429
|
-
if ($[52] !== normalizedContent) {
|
|
1430
|
-
t27 = /* @__PURE__ */ jsx(options.component, { content: normalizedContent });
|
|
1431
|
-
$[52] = normalizedContent;
|
|
1432
|
-
$[53] = t27;
|
|
1433
|
-
} else t27 = $[53];
|
|
1434
|
-
let t28;
|
|
1435
|
-
if ($[54] !== t26 || $[55] !== t27) {
|
|
1436
|
-
t28 = /* @__PURE__ */ jsx(Context.Provider, {
|
|
1437
|
-
value: t26,
|
|
1438
|
-
children: t27
|
|
1439
|
-
});
|
|
1440
|
-
$[54] = t26;
|
|
1441
|
-
$[55] = t27;
|
|
1442
|
-
$[56] = t28;
|
|
1443
|
-
} else t28 = $[56];
|
|
1444
|
-
const t29 = shouldShowAddBlockOverlay || void 0;
|
|
1445
|
-
let t30;
|
|
1446
|
-
if ($[57] !== t29) {
|
|
1447
|
-
t30 = /* @__PURE__ */ jsx("div", {
|
|
1448
|
-
className: "camox-sheet-overlay",
|
|
1449
|
-
"data-camox-visible": t29
|
|
1450
|
-
});
|
|
1451
|
-
$[57] = t29;
|
|
1452
|
-
$[58] = t30;
|
|
1453
|
-
} else t30 = $[58];
|
|
1454
|
-
let t31;
|
|
1455
|
-
if ($[59] !== handleAddBlockClick || $[60] !== isAddBlockSidebarOpen || $[61] !== isFirstBlock || $[62] !== mode || $[63] !== shouldShowOverlay || $[64] !== showAddBlockBottom || $[65] !== showAddBlockTop) {
|
|
1456
|
-
t31 = shouldShowOverlay && /* @__PURE__ */ jsxs(Fragment, { children: [(showAddBlockTop ?? (mode !== "layout" && !isFirstBlock)) && /* @__PURE__ */ jsx(AddBlockControlBar, {
|
|
1457
|
-
position: "top",
|
|
1458
|
-
hidden: isAddBlockSidebarOpen,
|
|
1459
|
-
onMouseLeave: () => setIsHovered(false),
|
|
1460
|
-
onClick: () => handleAddBlockClick("before")
|
|
1461
|
-
}), (showAddBlockBottom ?? mode !== "layout") && /* @__PURE__ */ jsx(AddBlockControlBar, {
|
|
1462
|
-
position: "bottom",
|
|
1463
|
-
hidden: isAddBlockSidebarOpen,
|
|
1464
|
-
onMouseLeave: () => setIsHovered(false),
|
|
1465
|
-
onClick: () => handleAddBlockClick("after")
|
|
1466
|
-
})] });
|
|
1467
|
-
$[59] = handleAddBlockClick;
|
|
1468
|
-
$[60] = isAddBlockSidebarOpen;
|
|
1469
|
-
$[61] = isFirstBlock;
|
|
1470
|
-
$[62] = mode;
|
|
1471
|
-
$[63] = shouldShowOverlay;
|
|
1472
|
-
$[64] = showAddBlockBottom;
|
|
1473
|
-
$[65] = showAddBlockTop;
|
|
1474
|
-
$[66] = t31;
|
|
1475
|
-
} else t31 = $[66];
|
|
1476
|
-
let t32;
|
|
1477
|
-
if ($[67] !== handleClick || $[68] !== handleMouseEnter || $[69] !== handleMouseLeave || $[70] !== t16 || $[71] !== t17 || $[72] !== t18 || $[73] !== t19 || $[74] !== t28 || $[75] !== t30 || $[76] !== t31) {
|
|
1478
|
-
t32 = /* @__PURE__ */ jsxs("div", {
|
|
1479
|
-
className: "group visual-editing-block",
|
|
1480
|
-
ref,
|
|
1481
|
-
style: t15,
|
|
1482
|
-
"data-camox-block-id": t16,
|
|
1483
|
-
"data-camox-hovered": t17,
|
|
1484
|
-
"data-camox-focused": t18,
|
|
1485
|
-
"data-camox-overlay-mode": t19,
|
|
1486
|
-
onClick: handleClick,
|
|
1487
|
-
onMouseEnter: handleMouseEnter,
|
|
1488
|
-
onMouseLeave: handleMouseLeave,
|
|
1489
|
-
children: [
|
|
1490
|
-
t28,
|
|
1491
|
-
t30,
|
|
1492
|
-
t31
|
|
1493
|
-
]
|
|
1494
|
-
});
|
|
1495
|
-
$[67] = handleClick;
|
|
1496
|
-
$[68] = handleMouseEnter;
|
|
1497
|
-
$[69] = handleMouseLeave;
|
|
1498
|
-
$[70] = t16;
|
|
1499
|
-
$[71] = t17;
|
|
1500
|
-
$[72] = t18;
|
|
1501
|
-
$[73] = t19;
|
|
1502
|
-
$[74] = t28;
|
|
1503
|
-
$[75] = t30;
|
|
1504
|
-
$[76] = t31;
|
|
1505
|
-
$[77] = t32;
|
|
1506
|
-
} else t32 = $[77];
|
|
1507
|
-
return t32;
|
|
1508
|
-
};
|
|
1509
|
-
const useSetting = (name) => {
|
|
1510
|
-
const ctx = React.use(Context);
|
|
1511
|
-
if (!ctx) throw new Error("useSetting must be used within a Block Component");
|
|
1512
|
-
return ctx.settings[name];
|
|
1513
|
-
};
|
|
1514
|
-
/**
|
|
1515
|
-
* Wraps block content that renders outside the block's visual bounds (fixed navbars, modals, portals, etc.).
|
|
1516
|
-
* Provides the same hover, selection, and sheet overlays as the main BlockComponent.
|
|
1517
|
-
*/
|
|
1518
|
-
const Detached = (t0) => {
|
|
1519
|
-
const $ = c(31);
|
|
1520
|
-
if ($[0] !== "9cd21990f1cb26b8613f764719b3c2aa84ab101438380ec49833d48adbdfe407") {
|
|
1521
|
-
for (let $i = 0; $i < 31; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
1522
|
-
$[0] = "9cd21990f1cb26b8613f764719b3c2aa84ab101438380ec49833d48adbdfe407";
|
|
1523
|
-
}
|
|
1524
|
-
const { children } = t0;
|
|
1525
|
-
const ctx = React.use(Context);
|
|
1526
|
-
if (!ctx) throw new Error("Detached must be used within a Block Component");
|
|
1527
|
-
const { blockId, mode, isHovered, setIsHovered } = ctx;
|
|
1528
|
-
const isContentEditable = useIsEditable(mode);
|
|
1529
|
-
const { window: iframeWindow } = useFrame();
|
|
1530
|
-
const selection = useSelector(previewStore, _temp0);
|
|
1531
|
-
const isAddBlockSidebarOpen = useSelector(previewStore, _temp1);
|
|
1532
|
-
const isBlockSelected = selection?.blockId === blockId;
|
|
1533
|
-
const t1 = String(blockId);
|
|
447
|
+
$[8] = blockData.settings;
|
|
448
|
+
$[9] = t1;
|
|
449
|
+
} else t1 = $[9];
|
|
1534
450
|
let t2;
|
|
1535
|
-
if ($[
|
|
1536
|
-
t2 = {
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
451
|
+
if ($[10] !== blockData._id || $[11] !== mergedContent || $[12] !== mode || $[13] !== t1) {
|
|
452
|
+
t2 = {
|
|
453
|
+
blockId: blockData._id,
|
|
454
|
+
content: mergedContent,
|
|
455
|
+
settings: t1,
|
|
456
|
+
mode
|
|
457
|
+
};
|
|
458
|
+
$[10] = blockData._id;
|
|
459
|
+
$[11] = mergedContent;
|
|
460
|
+
$[12] = mode;
|
|
461
|
+
$[13] = t1;
|
|
462
|
+
$[14] = t2;
|
|
463
|
+
} else t2 = $[14];
|
|
1541
464
|
let t3;
|
|
465
|
+
if ($[15] !== normalizedContent) {
|
|
466
|
+
t3 = /* @__PURE__ */ jsx(AuthoredComponent, { content: normalizedContent });
|
|
467
|
+
$[15] = normalizedContent;
|
|
468
|
+
$[16] = t3;
|
|
469
|
+
} else t3 = $[16];
|
|
1542
470
|
let t4;
|
|
1543
|
-
if ($[
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
$[
|
|
1549
|
-
$[
|
|
1550
|
-
$[
|
|
1551
|
-
|
|
1552
|
-
} else {
|
|
1553
|
-
t3 = $[5];
|
|
1554
|
-
t4 = $[6];
|
|
1555
|
-
}
|
|
1556
|
-
React.useEffect(t3, t4);
|
|
1557
|
-
const shouldShowOverlay = isContentEditable && (isHovered || isBlockSelected) && !isAddBlockSidebarOpen;
|
|
1558
|
-
const shouldHideForAddBlockSidebar = isAddBlockSidebarOpen && mode !== "peek";
|
|
471
|
+
if ($[17] !== t2 || $[18] !== t3) {
|
|
472
|
+
t4 = /* @__PURE__ */ jsx(Context.Provider, {
|
|
473
|
+
value: t2,
|
|
474
|
+
children: t3
|
|
475
|
+
});
|
|
476
|
+
$[17] = t2;
|
|
477
|
+
$[18] = t3;
|
|
478
|
+
$[19] = t4;
|
|
479
|
+
} else t4 = $[19];
|
|
1559
480
|
let t5;
|
|
1560
|
-
if ($[
|
|
1561
|
-
t5 = (
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
previewStore.send({
|
|
1565
|
-
type: "setFocusedBlock",
|
|
1566
|
-
blockId
|
|
1567
|
-
});
|
|
1568
|
-
};
|
|
1569
|
-
$[7] = blockId;
|
|
1570
|
-
$[8] = isContentEditable;
|
|
1571
|
-
$[9] = t5;
|
|
1572
|
-
} else t5 = $[9];
|
|
1573
|
-
const handleClick = t5;
|
|
481
|
+
if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
|
|
482
|
+
t5 = /* @__PURE__ */ jsx("div", { className: "camox-sheet-overlay" });
|
|
483
|
+
$[20] = t5;
|
|
484
|
+
} else t5 = $[20];
|
|
1574
485
|
let t6;
|
|
1575
|
-
if ($[
|
|
1576
|
-
t6 = (
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
$[11] = setIsHovered;
|
|
1581
|
-
$[12] = t6;
|
|
1582
|
-
} else t6 = $[12];
|
|
1583
|
-
const handleMouseEnter = t6;
|
|
1584
|
-
let t7;
|
|
1585
|
-
if ($[13] !== isContentEditable || $[14] !== setIsHovered) {
|
|
1586
|
-
t7 = () => {
|
|
1587
|
-
if (isContentEditable) setIsHovered(false);
|
|
1588
|
-
};
|
|
1589
|
-
$[13] = isContentEditable;
|
|
1590
|
-
$[14] = setIsHovered;
|
|
1591
|
-
$[15] = t7;
|
|
1592
|
-
} else t7 = $[15];
|
|
1593
|
-
const handleMouseLeave = t7;
|
|
1594
|
-
const [container, setContainer] = React.useState(null);
|
|
1595
|
-
const t8 = shouldHideForAddBlockSidebar ? 0 : 1;
|
|
1596
|
-
let t9;
|
|
1597
|
-
if ($[16] !== children || $[17] !== handleClick || $[18] !== handleMouseEnter || $[19] !== handleMouseLeave || $[20] !== t8) {
|
|
1598
|
-
t9 = children({
|
|
1599
|
-
ref: setContainer,
|
|
1600
|
-
style: { opacity: t8 },
|
|
1601
|
-
onClick: handleClick,
|
|
1602
|
-
onMouseEnter: handleMouseEnter,
|
|
1603
|
-
onMouseLeave: handleMouseLeave
|
|
486
|
+
if ($[21] !== t4) {
|
|
487
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
488
|
+
className: "group visual-editing-block",
|
|
489
|
+
style: t0,
|
|
490
|
+
children: [t4, t5]
|
|
1604
491
|
});
|
|
1605
|
-
$[
|
|
1606
|
-
$[
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
492
|
+
$[21] = t4;
|
|
493
|
+
$[22] = t6;
|
|
494
|
+
} else t6 = $[22];
|
|
495
|
+
return t6;
|
|
496
|
+
};
|
|
497
|
+
const contentSchema = {
|
|
498
|
+
type: "object",
|
|
499
|
+
title: options.title,
|
|
500
|
+
description: options.description,
|
|
501
|
+
properties: typeboxSchema.properties,
|
|
502
|
+
required: Object.keys(options.content),
|
|
503
|
+
toMarkdown: resolveToMarkdown(options.toMarkdown, options.settings, "block")
|
|
504
|
+
};
|
|
505
|
+
const settingsSchema = settingsTypeboxSchema ? {
|
|
506
|
+
type: "object",
|
|
507
|
+
properties: settingsTypeboxSchema.properties,
|
|
508
|
+
required: Object.keys(options.settings ?? {})
|
|
509
|
+
} : void 0;
|
|
510
|
+
const getInitialBundle = () => {
|
|
511
|
+
const content = { ...contentDefaults };
|
|
512
|
+
const repeatableItems = [];
|
|
513
|
+
buildInitialItems(typeboxSchema.properties, null, content, repeatableItems, { value: 0 });
|
|
514
|
+
const storageContent = {};
|
|
515
|
+
for (const [key, property] of Object.entries(typeboxSchema.properties)) {
|
|
516
|
+
if ([
|
|
517
|
+
"Image",
|
|
518
|
+
"File",
|
|
519
|
+
"ImageList",
|
|
520
|
+
"FileList",
|
|
521
|
+
"Repeater"
|
|
522
|
+
].includes(property.fieldType)) continue;
|
|
523
|
+
if ("default" in property) storageContent[key] = property.default;
|
|
524
|
+
}
|
|
525
|
+
return {
|
|
526
|
+
content: storageContent,
|
|
527
|
+
settings: { ...settingsDefaults },
|
|
528
|
+
repeatableItems
|
|
529
|
+
};
|
|
1641
530
|
};
|
|
1642
531
|
return {
|
|
1643
532
|
Detached,
|
|
@@ -1651,50 +540,33 @@ function createBlock(options) {
|
|
|
1651
540
|
Repeater,
|
|
1652
541
|
useSetting,
|
|
1653
542
|
_internal: {
|
|
1654
|
-
|
|
1655
|
-
* The react component to be used at the page level when mapping on blocks content.
|
|
1656
|
-
* It exposes context that will be consumed by the Field component, and provides visual editing
|
|
1657
|
-
* capabilities (e.g. delete and reorder blocks).
|
|
1658
|
-
*/
|
|
1659
|
-
Component: BlockComponent,
|
|
543
|
+
Component,
|
|
1660
544
|
id: options.id,
|
|
1661
545
|
title: options.title,
|
|
1662
546
|
description: options.description,
|
|
1663
547
|
contentSchema,
|
|
1664
548
|
settingsSchema,
|
|
1665
549
|
layoutOnly: options.layoutOnly ?? false,
|
|
1666
|
-
getInitialBundle
|
|
1667
|
-
const counter = { value: 0 };
|
|
1668
|
-
const allSeeds = [];
|
|
1669
|
-
const content = { ...contentDefaults };
|
|
1670
|
-
buildInitialSeeds(typeboxSchema.properties, null, content, allSeeds, counter);
|
|
1671
|
-
const storageContent = {};
|
|
1672
|
-
for (const [key, prop] of Object.entries(typeboxSchema.properties)) {
|
|
1673
|
-
const ft = prop.fieldType;
|
|
1674
|
-
if (ft === "Image" || ft === "File" || ft === "ImageList" || ft === "FileList" || ft === "Repeater") continue;
|
|
1675
|
-
if ("default" in prop) storageContent[key] = prop.default;
|
|
1676
|
-
}
|
|
1677
|
-
return {
|
|
1678
|
-
content: storageContent,
|
|
1679
|
-
settings: { ...settingsDefaults },
|
|
1680
|
-
repeatableItems: allSeeds
|
|
1681
|
-
};
|
|
1682
|
-
},
|
|
550
|
+
getInitialBundle,
|
|
1683
551
|
getInitialContent: () => {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
552
|
+
const content = { ...contentDefaults };
|
|
553
|
+
for (const [key, property] of Object.entries(typeboxSchema.properties)) if ([
|
|
554
|
+
"Image",
|
|
555
|
+
"File",
|
|
556
|
+
"ImageList",
|
|
557
|
+
"FileList",
|
|
558
|
+
"Repeater"
|
|
559
|
+
].includes(property.fieldType)) delete content[key];
|
|
560
|
+
return content;
|
|
1688
561
|
},
|
|
562
|
+
getInitialSettings: () => ({ ...settingsDefaults }),
|
|
1689
563
|
getPeekBundle: () => {
|
|
1690
|
-
const PEEK_BLOCK_ID = -1;
|
|
1691
|
-
const counter = { value: 0 };
|
|
1692
|
-
const allItems = [];
|
|
1693
564
|
const content = { ...contentDefaults };
|
|
1694
|
-
|
|
565
|
+
const repeatableItems = [];
|
|
566
|
+
buildPeekItems(typeboxSchema.properties, -1, null, content, repeatableItems, { value: 0 });
|
|
1695
567
|
return {
|
|
1696
568
|
block: {
|
|
1697
|
-
id:
|
|
569
|
+
id: -1,
|
|
1698
570
|
pageId: null,
|
|
1699
571
|
layoutId: null,
|
|
1700
572
|
type: options.id,
|
|
@@ -1706,46 +578,21 @@ function createBlock(options) {
|
|
|
1706
578
|
createdAt: 0,
|
|
1707
579
|
updatedAt: 0
|
|
1708
580
|
},
|
|
1709
|
-
repeatableItems
|
|
581
|
+
repeatableItems,
|
|
1710
582
|
files: []
|
|
1711
583
|
};
|
|
1712
584
|
}
|
|
1713
585
|
}
|
|
1714
586
|
};
|
|
1715
587
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
}
|
|
1719
|
-
function
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
function _temp3(e_2) {
|
|
1723
|
-
if (e_2.key === "Escape") e_2.target.blur();
|
|
1724
|
-
}
|
|
1725
|
-
function _temp4(e_3) {
|
|
1726
|
-
return e_3.preventDefault();
|
|
1727
|
-
}
|
|
1728
|
-
function _temp5(state) {
|
|
1729
|
-
return state.context.selection;
|
|
1730
|
-
}
|
|
1731
|
-
function _temp6(state_0) {
|
|
1732
|
-
return state_0.context.isPageEditorSidebarOpen;
|
|
1733
|
-
}
|
|
1734
|
-
function _temp7(state_1) {
|
|
1735
|
-
return state_1.context.isAddBlockSidebarOpen;
|
|
1736
|
-
}
|
|
1737
|
-
function _temp8(state_2) {
|
|
1738
|
-
return state_2.context.pendingAgentBlockFocus;
|
|
1739
|
-
}
|
|
1740
|
-
function _temp9(item) {
|
|
588
|
+
const createBlock = createViewBlock;
|
|
589
|
+
function _temp() {}
|
|
590
|
+
function _temp2() {}
|
|
591
|
+
function _temp3() {}
|
|
592
|
+
function _temp4() {}
|
|
593
|
+
function _temp5(item) {
|
|
1741
594
|
return item.content;
|
|
1742
595
|
}
|
|
1743
|
-
function _temp0(state) {
|
|
1744
|
-
return state.context.selection;
|
|
1745
|
-
}
|
|
1746
|
-
function _temp1(state_0) {
|
|
1747
|
-
return state_0.context.isAddBlockSidebarOpen;
|
|
1748
|
-
}
|
|
1749
596
|
|
|
1750
597
|
//#endregion
|
|
1751
598
|
export { Type, createBlock };
|