@conloca/cms-spa 0.2.0 → 0.2.2
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/spa/main.css +17 -3
- package/dist/ts/App.d.ts +5 -1
- package/dist/ts/App.d.ts.map +1 -1
- package/dist/ts/App.js +7 -2
- package/dist/ts/App.js.map +1 -1
- package/dist/ts/components/CMSDashboard.d.ts.map +1 -1
- package/dist/ts/components/CMSDashboard.js +6 -2
- package/dist/ts/components/CMSDashboard.js.map +1 -1
- package/dist/ts/components/RouteErrorPage.d.ts +11 -0
- package/dist/ts/components/RouteErrorPage.d.ts.map +1 -0
- package/dist/ts/components/RouteErrorPage.js +44 -0
- package/dist/ts/components/RouteErrorPage.js.map +1 -0
- package/dist/ts/components/cards/DataEntryCard.d.ts +1 -1
- package/dist/ts/components/cards/DataEntryCard.d.ts.map +1 -1
- package/dist/ts/components/cards/SectionCard.d.ts +1 -1
- package/dist/ts/components/cards/SectionCard.d.ts.map +1 -1
- package/dist/ts/components/dashboard/RecentActivity.d.ts.map +1 -1
- package/dist/ts/components/dashboard/RecentActivity.js +2 -8
- package/dist/ts/components/dashboard/RecentActivity.js.map +1 -1
- package/dist/ts/components/dialogs/CreateDataDialog.js +2 -2
- package/dist/ts/components/dialogs/CreateDataDialog.js.map +1 -1
- package/dist/ts/components/dialogs/CreateFolderDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/CreateFolderDialog.js +2 -1
- package/dist/ts/components/dialogs/CreateFolderDialog.js.map +1 -1
- package/dist/ts/components/dialogs/CreatePageFlow.d.ts +13 -0
- package/dist/ts/components/dialogs/CreatePageFlow.d.ts.map +1 -0
- package/dist/ts/components/dialogs/CreatePageFlow.js +100 -0
- package/dist/ts/components/dialogs/CreatePageFlow.js.map +1 -0
- package/dist/ts/components/dialogs/DataPropertiesDialog.d.ts +1 -1
- package/dist/ts/components/dialogs/DataPropertiesDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/DataPropertiesDialog.js +2 -2
- package/dist/ts/components/dialogs/DataPropertiesDialog.js.map +1 -1
- package/dist/ts/components/dialogs/DeleteConfirmDialog.d.ts +1 -1
- package/dist/ts/components/dialogs/DeleteConfirmDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts +2 -2
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.js +2 -2
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.js.map +1 -1
- package/dist/ts/components/dialogs/MoveFolderDialog.d.ts +1 -1
- package/dist/ts/components/dialogs/MoveFolderDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/PageMetadataDialog.d.ts +2 -12
- package/dist/ts/components/dialogs/PageMetadataDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/PageMetadataDialog.js +3 -21
- package/dist/ts/components/dialogs/PageMetadataDialog.js.map +1 -1
- package/dist/ts/components/editor/DrawerItemOverride.d.ts +2 -0
- package/dist/ts/components/editor/DrawerItemOverride.d.ts.map +1 -1
- package/dist/ts/components/editor/DrawerItemOverride.js +4 -3
- package/dist/ts/components/editor/DrawerItemOverride.js.map +1 -1
- package/dist/ts/components/editor/GenericBlock.js +2 -2
- package/dist/ts/components/editor/GenericBlock.js.map +1 -1
- package/dist/ts/components/editor/LocaleSelector.d.ts +1 -1
- package/dist/ts/components/editor/LocaleSelector.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditor.d.ts +7 -8
- package/dist/ts/components/editor/PageEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditor.js +78 -17
- package/dist/ts/components/editor/PageEditor.js.map +1 -1
- package/dist/ts/components/editor/PageEditorHeaderActions.d.ts +1 -1
- package/dist/ts/components/editor/PageEditorHeaderActions.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditorHeaderActions.js +1 -1
- package/dist/ts/components/editor/PageEditorHeaderActions.js.map +1 -1
- package/dist/ts/components/editor/PageEditorWrapper.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditorWrapper.js +17 -7
- package/dist/ts/components/editor/PageEditorWrapper.js.map +1 -1
- package/dist/ts/components/editor/draft-media-config.d.ts +4 -0
- package/dist/ts/components/editor/draft-media-config.d.ts.map +1 -0
- package/dist/ts/components/editor/draft-media-config.js +95 -0
- package/dist/ts/components/editor/draft-media-config.js.map +1 -0
- package/dist/ts/components/editor/page-setting-targets.d.ts +1 -1
- package/dist/ts/components/editor/page-setting-targets.d.ts.map +1 -1
- package/dist/ts/components/editors/DataEditor.d.ts +3 -3
- package/dist/ts/components/editors/DataEditor.d.ts.map +1 -1
- package/dist/ts/components/forms/HintForm.js +8 -5
- package/dist/ts/components/forms/HintForm.js.map +1 -1
- package/dist/ts/components/forms/SchemaForm.d.ts +17 -5
- package/dist/ts/components/forms/SchemaForm.d.ts.map +1 -1
- package/dist/ts/components/forms/SchemaForm.js +16 -9
- package/dist/ts/components/forms/SchemaForm.js.map +1 -1
- package/dist/ts/components/media/AssetCard.d.ts +1 -1
- package/dist/ts/components/media/AssetCard.d.ts.map +1 -1
- package/dist/ts/components/media/AssetDetailSidebar.d.ts +1 -1
- package/dist/ts/components/media/AssetDetailSidebar.d.ts.map +1 -1
- package/dist/ts/components/media/FolderTreeSidebar.d.ts.map +1 -1
- package/dist/ts/components/media/FolderTreeSidebar.js +4 -1
- package/dist/ts/components/media/FolderTreeSidebar.js.map +1 -1
- package/dist/ts/components/media/MediaLibrary.d.ts +1 -1
- package/dist/ts/components/media/MediaLibrary.d.ts.map +1 -1
- package/dist/ts/components/media/MediaToolbar.d.ts +1 -1
- package/dist/ts/components/media/MediaToolbar.d.ts.map +1 -1
- package/dist/ts/components/pages/DataList.d.ts.map +1 -1
- package/dist/ts/components/pages/DataList.js +6 -4
- package/dist/ts/components/pages/DataList.js.map +1 -1
- package/dist/ts/components/pages/PageList.d.ts.map +1 -1
- package/dist/ts/components/pages/PageList.js +4 -96
- package/dist/ts/components/pages/PageList.js.map +1 -1
- package/dist/ts/components/sandbox/ContentSandbox.d.ts +1 -1
- package/dist/ts/components/sandbox/ContentSandbox.d.ts.map +1 -1
- package/dist/ts/components/ui/IconButton.d.ts +1 -1
- package/dist/ts/components/ui/IconButton.d.ts.map +1 -1
- package/dist/ts/content-form-fields.d.ts +41 -0
- package/dist/ts/content-form-fields.d.ts.map +1 -0
- package/dist/ts/content-form-fields.js +70 -0
- package/dist/ts/content-form-fields.js.map +1 -0
- package/dist/ts/data-schemas.d.ts +4 -3
- package/dist/ts/data-schemas.d.ts.map +1 -1
- package/dist/ts/data-schemas.js.map +1 -1
- package/dist/ts/host-discovery.d.ts.map +1 -1
- package/dist/ts/host-schema.d.ts +73 -0
- package/dist/ts/host-schema.d.ts.map +1 -0
- package/dist/ts/host-schema.js +66 -0
- package/dist/ts/host-schema.js.map +1 -0
- package/dist/ts/host-style-probe.d.ts.map +1 -1
- package/dist/ts/host-style-probe.js +16 -0
- package/dist/ts/host-style-probe.js.map +1 -1
- package/dist/ts/main-spa.d.ts.map +1 -1
- package/dist/ts/main-spa.js +2 -3
- package/dist/ts/main-spa.js.map +1 -1
- package/dist/ts/page-schema-define.d.ts +14 -12
- package/dist/ts/page-schema-define.d.ts.map +1 -1
- package/dist/ts/page-schema-define.js +8 -5
- package/dist/ts/page-schema-define.js.map +1 -1
- package/dist/ts/page-schemas.d.ts.map +1 -1
- package/dist/ts/puck-config.d.ts.map +1 -1
- package/dist/ts/selected-block.d.ts.map +1 -1
- package/dist/ts/site-styles.d.ts +3 -2
- package/dist/ts/site-styles.d.ts.map +1 -1
- package/dist/ts/site-styles.js +6 -4
- package/dist/ts/site-styles.js.map +1 -1
- package/dist/ts/ui-config.d.ts +13 -4
- package/dist/ts/ui-config.d.ts.map +1 -1
- package/dist/ts/ui-config.js +9 -0
- package/dist/ts/ui-config.js.map +1 -1
- package/dist/ts/utils/asset-url.d.ts +2 -0
- package/dist/ts/utils/asset-url.d.ts.map +1 -1
- package/dist/ts/utils/asset-url.js +7 -0
- package/dist/ts/utils/asset-url.js.map +1 -1
- package/dist/ts/utils/pageMetadata.d.ts.map +1 -1
- package/dist/ts/utils/pageMetadata.js +27 -10
- package/dist/ts/utils/pageMetadata.js.map +1 -1
- package/dist/ts/utils/schema-fields.d.ts +23 -0
- package/dist/ts/utils/schema-fields.d.ts.map +1 -0
- package/dist/ts/utils/schema-fields.js +82 -0
- package/dist/ts/utils/schema-fields.js.map +1 -0
- package/package.json +41 -13
- package/src/App.tsx +13 -4
- package/src/components/CMSDashboard.tsx +12 -4
- package/src/components/RouteErrorPage.tsx +75 -0
- package/src/components/dashboard/RecentActivity.tsx +3 -7
- package/src/components/dialogs/CreateDataDialog.tsx +2 -2
- package/src/components/dialogs/CreateFolderDialog.tsx +2 -1
- package/src/components/dialogs/CreatePageFlow.tsx +117 -0
- package/src/components/dialogs/DataPropertiesDialog.tsx +3 -2
- package/src/components/dialogs/FragmentPropertiesDialog.tsx +3 -2
- package/src/components/dialogs/PageMetadataDialog.tsx +5 -28
- package/src/components/editor/DrawerItemOverride.tsx +14 -8
- package/src/components/editor/GenericBlock.tsx +2 -2
- package/src/components/editor/PageEditor.tsx +90 -19
- package/src/components/editor/PageEditorHeaderActions.tsx +1 -1
- package/src/components/editor/PageEditorWrapper.tsx +17 -7
- package/src/components/editor/draft-media-config.ts +95 -0
- package/src/components/editors/DataEditor.tsx +2 -2
- package/src/components/forms/HintForm.tsx +7 -5
- package/src/components/forms/SchemaForm.tsx +41 -12
- package/src/components/media/FolderTreeSidebar.tsx +3 -1
- package/src/components/pages/DataList.tsx +6 -4
- package/src/components/pages/PageList.tsx +6 -116
- package/src/content-form-fields.ts +79 -0
- package/src/data-schemas.ts +4 -3
- package/src/host-schema.ts +122 -0
- package/src/host-style-probe.ts +16 -0
- package/src/main-spa.tsx +2 -3
- package/src/main.css +10 -7
- package/src/page-schema-define.ts +29 -17
- package/src/site-styles.ts +6 -4
- package/src/ui-config.ts +16 -4
- package/src/utils/asset-url.ts +8 -0
- package/src/utils/pageMetadata.ts +27 -10
- package/src/utils/schema-fields.ts +106 -0
- package/dist/ts/utils/zodIntrospect.d.ts +0 -19
- package/dist/ts/utils/zodIntrospect.d.ts.map +0 -1
- package/dist/ts/utils/zodIntrospect.js +0 -95
- package/dist/ts/utils/zodIntrospect.js.map +0 -1
- package/src/utils/zodIntrospect.ts +0 -136
|
@@ -6,6 +6,9 @@ interface DrawerItemOverrideProps {
|
|
|
6
6
|
name: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/** Puck's root drop zone, which Puck does not export as a constant. */
|
|
10
|
+
export const PUCK_ROOT_DROP_ZONE = 'root:default-zone';
|
|
11
|
+
|
|
9
12
|
function generateId(componentType: string): string {
|
|
10
13
|
return `${componentType}-${crypto.randomUUID()}`;
|
|
11
14
|
}
|
|
@@ -24,8 +27,7 @@ export function DrawerItemOverride({ children, name }: DrawerItemOverrideProps)
|
|
|
24
27
|
type: 'insert',
|
|
25
28
|
componentType: name,
|
|
26
29
|
destinationIndex: puck.appState.data.content.length,
|
|
27
|
-
|
|
28
|
-
destinationZone: 'root:default-zone',
|
|
30
|
+
destinationZone: PUCK_ROOT_DROP_ZONE,
|
|
29
31
|
id,
|
|
30
32
|
recordHistory: true,
|
|
31
33
|
});
|
|
@@ -42,21 +44,25 @@ export function DrawerItemOverride({ children, name }: DrawerItemOverrideProps)
|
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
return (
|
|
47
|
+
// Not a real <button>: Puck's drag sensor refuses to start a drag from a press on an interactive element
|
|
48
|
+
// (button, link, input) inside a drawer item, so a <button> here made every block in the list undraggable.
|
|
45
49
|
// `block w-full`: this wrapper sits between Puck's drawer-item container
|
|
46
|
-
// and the row it lays out, so a default inline-block
|
|
50
|
+
// and the row it lays out, so a default inline-block wrapper would size to
|
|
47
51
|
// its content instead of the container. A drawer item's label is as wide
|
|
48
52
|
// as its text — a fragment is named after its content, so those names run
|
|
49
53
|
// past the sidebar — and the label's own `text-overflow: ellipsis` can
|
|
50
54
|
// only take effect while something above it is still bounded by the
|
|
51
|
-
// sidebar's width.
|
|
52
|
-
<button
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
// sidebar's width. `select-none` keeps a double-click from selecting the label's text, as it never did on a button.
|
|
56
|
+
// biome-ignore lint/a11y/useSemanticElements: a <button> here would stop Puck from dragging the block (see above)
|
|
57
|
+
<div
|
|
58
|
+
role="button"
|
|
59
|
+
tabIndex={0}
|
|
60
|
+
className="block w-full select-none"
|
|
55
61
|
onDoubleClick={handleDoubleClick}
|
|
56
62
|
onKeyDown={handleKeyDown}
|
|
57
63
|
data-testid={`drawer-item-${name}`}
|
|
58
64
|
>
|
|
59
65
|
{children}
|
|
60
|
-
</
|
|
66
|
+
</div>
|
|
61
67
|
);
|
|
62
68
|
}
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from '../../mdx-components.js';
|
|
20
20
|
import { useSandboxPreviewStyles } from '../../sandbox-preview-styles.js';
|
|
21
21
|
import { getSelectedBlock, setSelectedBlock, useSelectedBlock } from '../../selected-block.js';
|
|
22
|
+
import { getCmsRoute } from '../../ui-config.js';
|
|
22
23
|
import { bodyNeedsStaticHtml, isHtmlTag, mdastToHtml } from '../../utils/mdast-to-html.js';
|
|
23
24
|
import {
|
|
24
25
|
effectiveChildren,
|
|
@@ -118,7 +119,6 @@ interface RenderRequest {
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
const SLOT_TAG = 'conloca-slot';
|
|
121
|
-
const RENDER_ENDPOINT = '/__cms/api/render';
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* Find string-prop values inside the SSR'd preview and make their rendering
|
|
@@ -405,7 +405,7 @@ async function fetchRendered(req: RenderRequest): Promise<string> {
|
|
|
405
405
|
const cached = renderCache.get(key);
|
|
406
406
|
if (cached !== undefined) return cached;
|
|
407
407
|
|
|
408
|
-
const res = await fetch(
|
|
408
|
+
const res = await fetch(`${getCmsRoute()}/api/render`, {
|
|
409
409
|
method: 'POST',
|
|
410
410
|
headers: { 'content-type': 'application/json' },
|
|
411
411
|
body: JSON.stringify(req),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DataContext, LocalizedEntry, UpdateResult } from '@conloca/content-api-client';
|
|
2
|
-
import type
|
|
2
|
+
import { type Config, createUsePuck } from '@puckeditor/core';
|
|
3
3
|
import { Monitor, Smartphone, Tablet } from 'lucide-react';
|
|
4
4
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { notifyEditorDirtyChanged, registerEditorFlushHandler } from '../../editor-flush.js';
|
|
@@ -14,7 +14,8 @@ import { ConflictDialog } from '../dialogs/ConflictDialog.js';
|
|
|
14
14
|
import { UnsavedChangesDialog } from '../dialogs/UnsavedChangesDialog.js';
|
|
15
15
|
import { ImageFieldRender } from '../fields/ImageField.js';
|
|
16
16
|
import { toast } from '../toast.js';
|
|
17
|
-
import { DrawerItemOverride } from './DrawerItemOverride.js';
|
|
17
|
+
import { DrawerItemOverride, PUCK_ROOT_DROP_ZONE } from './DrawerItemOverride.js';
|
|
18
|
+
import { withDraftMediaRendering } from './draft-media-config.js';
|
|
18
19
|
import { PageEditorHeaderActions } from './PageEditorHeaderActions.js';
|
|
19
20
|
import { PuckWithUntouchedMetadata } from './PuckWithUntouchedMetadata.js';
|
|
20
21
|
import {
|
|
@@ -44,6 +45,20 @@ const viewports = [
|
|
|
44
45
|
{ width: 1280, height: 'auto' as const, label: 'Desktop', icon: <Monitor size={16} /> },
|
|
45
46
|
];
|
|
46
47
|
|
|
48
|
+
/**
|
|
49
|
+
* The canvas options, a module constant on purpose. `<Puck>` re-runs its canvas viewport effect whenever `iframe`
|
|
50
|
+
* changes identity (https://github.com/puckeditor/puck/pull/1864, open against 0.23), and while the undo history
|
|
51
|
+
* still holds only its first entry that effect overwrites the entry with the page as it is by then. This editor
|
|
52
|
+
* re-renders on every edit, so an inline object would replace the loaded page in the history with the result of the
|
|
53
|
+
* first edit before Puck records that edit: Undo would then flip the history buttons and leave the edit on the canvas.
|
|
54
|
+
*
|
|
55
|
+
* The canvas shows the SITE, so it gets the site's stylesheets and nothing else. Puck's default mirrors this admin
|
|
56
|
+
* document's head into the iframe, which for a consumer whose editor and site are separate apps means the CMS
|
|
57
|
+
* chrome's own CSS lands on top of the page being edited — Tailwind's preflight there flattens headings the site
|
|
58
|
+
* styles by element rather than by utility class.
|
|
59
|
+
*/
|
|
60
|
+
const CANVAS_IFRAME = { syncHostStyles: false };
|
|
61
|
+
|
|
47
62
|
/**
|
|
48
63
|
* Stable field type overrides for Puck.
|
|
49
64
|
* Defined at module level to maintain referential stability across renders.
|
|
@@ -77,6 +92,29 @@ const drawerItemOverride = ({ children, name }: { children: React.ReactNode; nam
|
|
|
77
92
|
<DrawerItemOverride name={name}>{children}</DrawerItemOverride>
|
|
78
93
|
);
|
|
79
94
|
|
|
95
|
+
/** On the canvas's scaled-down view (about half size) this still reads at a normal text size. */
|
|
96
|
+
const EMPTY_PAGE_HINT_FONT_SIZE = '24px';
|
|
97
|
+
|
|
98
|
+
const EMPTY_PAGE_HINT = 'Drag a block here, or double-click one in the list';
|
|
99
|
+
|
|
100
|
+
const EMPTY_PAGE_HINT_DECLARATIONS = [
|
|
101
|
+
`content: ${JSON.stringify(EMPTY_PAGE_HINT)}`,
|
|
102
|
+
'display: flex',
|
|
103
|
+
'align-items: center',
|
|
104
|
+
'justify-content: center',
|
|
105
|
+
'box-sizing: border-box',
|
|
106
|
+
'height: 100%',
|
|
107
|
+
'min-height: inherit',
|
|
108
|
+
'padding: 16px',
|
|
109
|
+
'text-align: center',
|
|
110
|
+
'font-family: var(--puck-font-family)',
|
|
111
|
+
`font-size: ${EMPTY_PAGE_HINT_FONT_SIZE}`,
|
|
112
|
+
'color: var(--puck-color-grey-05)',
|
|
113
|
+
].join('; ');
|
|
114
|
+
|
|
115
|
+
const CAN_INSERT_ATTRIBUTE = 'data-conloca-can-insert';
|
|
116
|
+
const CAN_INSERT_SELECTOR = `html[${CAN_INSERT_ATTRIBUTE}]`;
|
|
117
|
+
|
|
80
118
|
/**
|
|
81
119
|
* An editing rule the preview canvas gets from the CMS. The <Puck> below
|
|
82
120
|
* opts out of Puck's host-style mirror, so main.css never reaches the canvas;
|
|
@@ -91,9 +129,27 @@ const drawerItemOverride = ({ children, name }: { children: React.ReactNode; nam
|
|
|
91
129
|
* a child), keeps Puck's highlight. `[data-puck-dropzone]` is the attribute
|
|
92
130
|
* Puck puts on every drop area; matching class names would also catch Puck's
|
|
93
131
|
* drop-position line and hide it.
|
|
132
|
+
*
|
|
133
|
+
* A page with no blocks also says how to add one: the empty root area is the
|
|
134
|
+
* whole canvas, so a line of text centred in it is where an author looks first.
|
|
135
|
+
* It is the area's `::before`, so it goes as soon as the area holds a block or
|
|
136
|
+
* a drop preview, and it never becomes content that can be saved. It is sized
|
|
137
|
+
* for the canvas's scaled-down view, where it must stay readable. It shows in
|
|
138
|
+
* edit mode only (the interactive preview renders the published page) and only
|
|
139
|
+
* while the editor marks the canvas as one that can take a block, because both
|
|
140
|
+
* ways the hint names do nothing when no block may be inserted.
|
|
94
141
|
*/
|
|
95
|
-
const EMPTY_DROP_AREA_CSS =
|
|
96
|
-
'[data-puck-dropzone]:empty { --puck-slot-color-bg: transparent; --puck-slot-color-border: var(--puck-color-grey-07); }'
|
|
142
|
+
const EMPTY_DROP_AREA_CSS = [
|
|
143
|
+
'[data-puck-dropzone]:empty { --puck-slot-color-bg: transparent; --puck-slot-color-border: var(--puck-color-grey-07); }',
|
|
144
|
+
`${CAN_INSERT_SELECTOR} [data-puck-entry][data-puck-preview-mode="edit"] [data-puck-dropzone="${PUCK_ROOT_DROP_ZONE}"]:empty::before { ${EMPTY_PAGE_HINT_DECLARATIONS} }`,
|
|
145
|
+
].join('\n');
|
|
146
|
+
|
|
147
|
+
const usePuck = createUsePuck();
|
|
148
|
+
|
|
149
|
+
/** Whether any block may be added to the page: the hint's two ways of adding one both need it. */
|
|
150
|
+
function usePageCanTakeAnInsert(): boolean {
|
|
151
|
+
return usePuck((state) => Object.keys(state.config.components).some((type) => state.getPermissions({ type }).insert));
|
|
152
|
+
}
|
|
97
153
|
|
|
98
154
|
/**
|
|
99
155
|
* Bridges CMS editor state into Puck's preview iframe.
|
|
@@ -108,12 +164,11 @@ const EMPTY_DROP_AREA_CSS =
|
|
|
108
164
|
* rules (e.g. `body { color: var(...) }`) cannot cascade into Puck's
|
|
109
165
|
* chrome — the iframe is the only intended consumer.
|
|
110
166
|
*
|
|
111
|
-
* The `<Puck>` below turns off Puck's host-style mirror
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* cleanup.
|
|
167
|
+
* The `<Puck>` below turns off Puck's host-style mirror (`CANVAS_IFRAME`),
|
|
168
|
+
* so the iframe head holds only Puck's own interaction CSS, the
|
|
169
|
+
* empty-drop-area rule (point 3), the page-setting cursor rule (point 4)
|
|
170
|
+
* and these tags. Nothing else touches them, so they are appended on
|
|
171
|
+
* every `siteStyles` change and removed on cleanup.
|
|
117
172
|
*
|
|
118
173
|
* 3. Injects `EMPTY_DROP_AREA_CSS` once per iframe document.
|
|
119
174
|
*
|
|
@@ -188,6 +243,23 @@ export function IframeBridge({ children, document: iframeDoc }: { children: Reac
|
|
|
188
243
|
return <>{children}</>;
|
|
189
244
|
}
|
|
190
245
|
|
|
246
|
+
/**
|
|
247
|
+
* `IframeBridge` for the canvas inside <Puck>: also marks the canvas document while the page can take a block, which
|
|
248
|
+
* the empty-page hint in `EMPTY_DROP_AREA_CSS` waits for. Separate because the marker reads Puck's state, so it only
|
|
249
|
+
* works inside <Puck>, while the bridge also renders on its own.
|
|
250
|
+
*/
|
|
251
|
+
function IframeWithInsertMarker({ children, document: iframeDoc }: { children: React.ReactNode; document?: Document }) {
|
|
252
|
+
const canTakeAnInsert = usePageCanTakeAnInsert();
|
|
253
|
+
React.useEffect(() => {
|
|
254
|
+
const html = iframeDoc?.documentElement;
|
|
255
|
+
if (!html) return undefined;
|
|
256
|
+
html.toggleAttribute(CAN_INSERT_ATTRIBUTE, canTakeAnInsert);
|
|
257
|
+
return () => html.removeAttribute(CAN_INSERT_ATTRIBUTE);
|
|
258
|
+
}, [iframeDoc, canTakeAnInsert]);
|
|
259
|
+
|
|
260
|
+
return <IframeBridge document={iframeDoc}>{children}</IframeBridge>;
|
|
261
|
+
}
|
|
262
|
+
|
|
191
263
|
export function PageEditor({
|
|
192
264
|
entry,
|
|
193
265
|
config,
|
|
@@ -200,6 +272,11 @@ export function PageEditor({
|
|
|
200
272
|
onReload,
|
|
201
273
|
onPublish,
|
|
202
274
|
}: PageEditorProps) {
|
|
275
|
+
const draftAssetsBasePath = getUIConfig().draftAssetsBasePath;
|
|
276
|
+
const renderConfig = useMemo(
|
|
277
|
+
() => withDraftMediaRendering(config, draftAssetsBasePath),
|
|
278
|
+
[config, draftAssetsBasePath],
|
|
279
|
+
);
|
|
203
280
|
const [data, setData] = useState(entry.localized.content.puckData);
|
|
204
281
|
const [saveState, setSaveState] = useState<SaveState>('idle');
|
|
205
282
|
const [isDirty, setIsDirty] = useState(false);
|
|
@@ -436,7 +513,7 @@ export function PageEditor({
|
|
|
436
513
|
},
|
|
437
514
|
drawerItem: drawerItemOverride,
|
|
438
515
|
fields: FieldsWithPageSettingsHint,
|
|
439
|
-
iframe:
|
|
516
|
+
iframe: IframeWithInsertMarker,
|
|
440
517
|
}),
|
|
441
518
|
[],
|
|
442
519
|
);
|
|
@@ -465,20 +542,14 @@ export function PageEditor({
|
|
|
465
542
|
<PageSettingTargetsProvider onOpen={onOpenMetadata}>
|
|
466
543
|
{/* Not <Puck> itself: on the canvas Puck rewrites the page data it hands blocks; see PuckWithUntouchedMetadata.tsx. */}
|
|
467
544
|
<PuckWithUntouchedMetadata
|
|
468
|
-
config={
|
|
545
|
+
config={renderConfig}
|
|
469
546
|
data={data}
|
|
470
547
|
metadata={metadata}
|
|
471
548
|
onChange={handleDataChange}
|
|
472
549
|
headerTitle={entry.localized.meta.title || 'Untitled Page'}
|
|
473
550
|
viewports={viewports}
|
|
474
551
|
overrides={overrides}
|
|
475
|
-
|
|
476
|
-
// nothing else. Puck's default mirrors this admin document's head
|
|
477
|
-
// into the iframe, which for a consumer whose editor and site are
|
|
478
|
-
// separate apps means the CMS chrome's own CSS lands on top of the
|
|
479
|
-
// page being edited — Tailwind's preflight there flattens headings
|
|
480
|
-
// the site styles by element rather than by utility class.
|
|
481
|
-
iframe={{ syncHostStyles: false }}
|
|
552
|
+
iframe={CANVAS_IFRAME}
|
|
482
553
|
/>
|
|
483
554
|
</PageSettingTargetsProvider>
|
|
484
555
|
</div>
|
|
@@ -109,7 +109,7 @@ export function PageEditorHeaderActions({
|
|
|
109
109
|
onClick={onSave}
|
|
110
110
|
disabled={!isDirty && saveState !== 'error' && saveState !== 'conflict'}
|
|
111
111
|
className={cn(
|
|
112
|
-
'w-[100px] px-4 py-2 rounded-md text-sm transition-all duration-150 flex items-center justify-center gap-1 whitespace-nowrap font-medium',
|
|
112
|
+
'w-[100px] px-4 py-2 rounded-md text-sm transition-all duration-150 flex items-center justify-center gap-1 whitespace-nowrap font-medium disabled:cursor-not-allowed',
|
|
113
113
|
saveState === 'saved' && 'bg-green-10 text-green-06 cursor-pointer',
|
|
114
114
|
saveState === 'error' && 'bg-red-10 text-red-06 hover:bg-red-09 cursor-pointer',
|
|
115
115
|
saveState === 'conflict' && 'bg-yellow-10 text-yellow-06 hover:bg-yellow-09 cursor-pointer',
|
|
@@ -259,20 +259,30 @@ export function PageEditorWrapper({ puckConfig }: PageEditorWrapperProps) {
|
|
|
259
259
|
return <MdxPageEditor />;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
|
|
262
|
+
// Keyed by page: the route element survives navigation between pages, and
|
|
263
|
+
// the locale state must restart from the newly opened page's locales.
|
|
264
|
+
return <PuckPageEditorInner key={id} puckConfig={puckConfig} initialLocale={initialPageLocale(content.locales)} />;
|
|
263
265
|
}
|
|
264
266
|
|
|
265
|
-
|
|
267
|
+
/**
|
|
268
|
+
* The locale the editor opens a page in: English when the page has it, as
|
|
269
|
+
* before, otherwise a locale the page actually has — opening on a locale with
|
|
270
|
+
* no variant fails the load with no way to reach the switcher.
|
|
271
|
+
*/
|
|
272
|
+
function initialPageLocale(locales: Record<string, unknown>): string {
|
|
273
|
+
if (locales.en) return 'en';
|
|
274
|
+
return Object.keys(locales).find((locale) => locales[locale]) ?? 'en';
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function PuckPageEditorInner({ puckConfig, initialLocale }: PageEditorWrapperProps & { initialLocale: string }) {
|
|
266
278
|
const { id } = useParams();
|
|
267
279
|
const navigate = useNavigate();
|
|
268
280
|
const updateContent = useUpdateLocalized();
|
|
269
281
|
|
|
270
282
|
// Mirrors FragmentEditor / MdxPageEditor: derive the locale list from the
|
|
271
|
-
// host's sites config and let the editor switch between them.
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
// from the switcher PageEditor renders when availableLocales.length > 1.
|
|
275
|
-
const [currentLocale, setCurrentLocale] = useState<string>('en');
|
|
283
|
+
// host's sites config and let the editor switch between them. It opens on
|
|
284
|
+
// a locale the page has (see initialPageLocale).
|
|
285
|
+
const [currentLocale, setCurrentLocale] = useState<string>(initialLocale);
|
|
276
286
|
const { data: sitesConfig } = useSitesConfig();
|
|
277
287
|
const availableLocales = sitesConfig?.globalLocales || ['en'];
|
|
278
288
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** Resolve unpublished draft images for site renderers without changing Puck's persisted data. */
|
|
2
|
+
import { IMAGE_EXTENSION_MIME } from '@conloca/content-api-client';
|
|
3
|
+
import type { Config, Field, Fields } from '@puckeditor/core';
|
|
4
|
+
import { type ComponentType, createElement, isValidElement } from 'react';
|
|
5
|
+
import { appendAssetUrlPath } from '../../utils/asset-url.js';
|
|
6
|
+
|
|
7
|
+
function draftImageUrl(value: string, base: string): string {
|
|
8
|
+
if (!value.startsWith('/assets/')) return value;
|
|
9
|
+
const path = value.slice('/assets/'.length);
|
|
10
|
+
if (/[\\?#]/.test(path)) return value;
|
|
11
|
+
const segments = path.split('/');
|
|
12
|
+
for (const part of segments) {
|
|
13
|
+
if (
|
|
14
|
+
part === '' ||
|
|
15
|
+
part === '.' ||
|
|
16
|
+
part === '..' ||
|
|
17
|
+
[...part].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127)
|
|
18
|
+
) {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const filename = segments[segments.length - 1] ?? '';
|
|
23
|
+
const dot = filename.lastIndexOf('.');
|
|
24
|
+
if (dot <= 0) return value;
|
|
25
|
+
const extension = filename.slice(dot + 1).toLowerCase();
|
|
26
|
+
if (!Object.prototype.hasOwnProperty.call(IMAGE_EXTENSION_MIME, extension)) return value;
|
|
27
|
+
const encoded = segments.map((part) =>
|
|
28
|
+
encodeURIComponent(part).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`),
|
|
29
|
+
);
|
|
30
|
+
return appendAssetUrlPath(base, encoded.join('/'));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
34
|
+
if (value === null || typeof value !== 'object' || isValidElement(value)) return false;
|
|
35
|
+
const prototype: unknown = Object.getPrototypeOf(value);
|
|
36
|
+
return prototype === Object.prototype || prototype === null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function fieldValue(value: unknown, field: Field, base: string): unknown {
|
|
40
|
+
if (field.type === 'slot') return value;
|
|
41
|
+
if (typeof value === 'string') return draftImageUrl(value, base);
|
|
42
|
+
if (field.type === 'object' && isRecord(value)) return fieldProps(value, field.objectFields, base);
|
|
43
|
+
if (field.type === 'array' && Array.isArray(value)) {
|
|
44
|
+
const next = value.map((item: unknown) => (isRecord(item) ? fieldProps(item, field.arrayFields, base) : item));
|
|
45
|
+
return next.some((item, index) => item !== value[index]) ? next : value;
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function fieldProps(props: Record<string, unknown>, fields: Fields | undefined, base: string): Record<string, unknown> {
|
|
51
|
+
let next = props;
|
|
52
|
+
for (const [name, field] of Object.entries(fields ?? {})) {
|
|
53
|
+
if (name === 'puck' || name === 'children' || name === 'editMode') continue;
|
|
54
|
+
if (field === undefined || !Object.prototype.hasOwnProperty.call(props, name)) continue;
|
|
55
|
+
const value = fieldValue(props[name], field, base);
|
|
56
|
+
if (value === props[name]) continue;
|
|
57
|
+
if (next === props) next = { ...props };
|
|
58
|
+
next[name] = value;
|
|
59
|
+
}
|
|
60
|
+
return next;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Static declared fields bound traversal; dynamic field resolvers and runtime contexts remain untouched. */
|
|
64
|
+
export function withDraftMediaRendering(config: Config, base: string | undefined): Config {
|
|
65
|
+
if (base === undefined) return config;
|
|
66
|
+
const root = config.root;
|
|
67
|
+
const rootRender = root?.render;
|
|
68
|
+
return {
|
|
69
|
+
...config,
|
|
70
|
+
...(root && rootRender
|
|
71
|
+
? {
|
|
72
|
+
root: {
|
|
73
|
+
...root,
|
|
74
|
+
// Rendered as an element so memo/forwardRef roots keep working. Root props are a
|
|
75
|
+
// children/no-children union, so name the component's own prop type for createElement.
|
|
76
|
+
render: (props: Parameters<typeof rootRender>[0]) =>
|
|
77
|
+
createElement(rootRender as ComponentType<typeof props>, {
|
|
78
|
+
...props,
|
|
79
|
+
...fieldProps(props, root.fields, base),
|
|
80
|
+
}),
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
: {}),
|
|
84
|
+
components: Object.fromEntries(
|
|
85
|
+
Object.entries(config.components).map(([name, component]) => [
|
|
86
|
+
name,
|
|
87
|
+
{
|
|
88
|
+
...component,
|
|
89
|
+
render: (props: Parameters<typeof component.render>[0]) =>
|
|
90
|
+
createElement(component.render, { ...props, ...fieldProps(props, component.fields, base) }),
|
|
91
|
+
},
|
|
92
|
+
]),
|
|
93
|
+
),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getContentAPIClient, useLocalizedContent, useUpdateLocalized } from '@conloca/content-api-client';
|
|
2
2
|
import { AlertCircle, Code2, Loader2, Save } from 'lucide-react';
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
|
-
import type {
|
|
4
|
+
import type { HostSchema } from '../../host-schema.js';
|
|
5
5
|
import { contentFailureMessage } from '../../utils/content-failure.js';
|
|
6
6
|
import { UnsavedChangesDialog } from '../dialogs/UnsavedChangesDialog.js';
|
|
7
7
|
import { LocaleSelector } from '../editor/LocaleSelector.js';
|
|
@@ -12,7 +12,7 @@ interface DataEditorProps {
|
|
|
12
12
|
collection: string;
|
|
13
13
|
initialLocale: string;
|
|
14
14
|
existingLocales: string[];
|
|
15
|
-
schema:
|
|
15
|
+
schema: HostSchema | null;
|
|
16
16
|
onSave?: () => void;
|
|
17
17
|
onCancel?: () => void;
|
|
18
18
|
}
|
|
@@ -138,7 +138,9 @@ function HintField({ name, hint, value, onChange }: HintFieldProps) {
|
|
|
138
138
|
id={inputId}
|
|
139
139
|
type="datetime-local"
|
|
140
140
|
value={formatDateValue(value)}
|
|
141
|
-
|
|
141
|
+
// The picker's digits carry no zone or seconds; a host's `Format<'date-time'>`
|
|
142
|
+
// validator needs a full timestamp, so they are saved as the UTC instant they mean.
|
|
143
|
+
onChange={(e) => onChange(e.target.value ? `${e.target.value}:00.000Z` : undefined)}
|
|
142
144
|
/>
|
|
143
145
|
</Wrapper>
|
|
144
146
|
);
|
|
@@ -417,10 +419,10 @@ function formatLabel(name: string): string {
|
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
/**
|
|
420
|
-
* Host date hints
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
* authors west of UTC.
|
|
422
|
+
* Host date hints save the picker's digits as a UTC instant, and older pages
|
|
423
|
+
* may hold the bare zone-less digits, which readers also take as UTC. Slicing
|
|
424
|
+
* UTC hours off a Date or ISO string keeps the picker on that convention; local
|
|
425
|
+
* hours would shift the stored day across midnight for authors west of UTC.
|
|
424
426
|
*/
|
|
425
427
|
function formatDateValue(value: unknown): string {
|
|
426
428
|
if (!value) return '';
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { Loader2 } from 'lucide-react';
|
|
2
2
|
import { useId } from 'react';
|
|
3
|
-
import type
|
|
4
|
-
import { toDatetimeLocalValue } from '../../utils/pageMetadata.js';
|
|
5
|
-
import { type FieldInfo,
|
|
3
|
+
import { type HostSchema, isHostSchema } from '../../host-schema.js';
|
|
4
|
+
import { fromDatetimeLocalValue, toDatetimeLocalValue } from '../../utils/pageMetadata.js';
|
|
5
|
+
import { type FieldInfo, type FormFields, fieldsOfHostSchema } from '../../utils/schema-fields.js';
|
|
6
6
|
import { ImageFieldRender } from '../fields/ImageField.js';
|
|
7
7
|
import { Input, Select, Textarea } from '../ui/index.js';
|
|
8
8
|
import { ChipArrayField } from './ChipArrayField.js';
|
|
9
9
|
|
|
10
10
|
interface SchemaFormProps {
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A host-declared schema, rendered from its generated JSON Schema metadata.
|
|
13
|
+
* This is the dynamic path: a site's `pageSchemas`/`dataSchemas` entry exists
|
|
14
|
+
* only at runtime, so its field shape is read off the metadata it carries.
|
|
15
|
+
*/
|
|
16
|
+
schema?: HostSchema | null;
|
|
17
|
+
/**
|
|
18
|
+
* An already-resolved field record — how the CMS's own metadata sections are
|
|
19
|
+
* declared now that they are no longer schema objects (`content-form-fields`).
|
|
20
|
+
* Takes precedence over `schema` when both are given.
|
|
21
|
+
*/
|
|
22
|
+
fields?: FormFields | null;
|
|
12
23
|
values: Record<string, unknown>;
|
|
13
24
|
onChange: (values: Record<string, unknown>) => void;
|
|
14
25
|
isLoading?: boolean;
|
|
@@ -16,10 +27,10 @@ interface SchemaFormProps {
|
|
|
16
27
|
}
|
|
17
28
|
|
|
18
29
|
/**
|
|
19
|
-
* Renders a form
|
|
20
|
-
* Fields are rendered automatically based on
|
|
30
|
+
* Renders a form from a host schema or a field record.
|
|
31
|
+
* Fields are rendered automatically based on their {@link FieldInfo}.
|
|
21
32
|
*/
|
|
22
|
-
export function SchemaForm({ schema, values, onChange, isLoading, className }: SchemaFormProps) {
|
|
33
|
+
export function SchemaForm({ schema, fields, values, onChange, isLoading, className }: SchemaFormProps) {
|
|
23
34
|
const handleFieldChange = (field: string, value: unknown) => {
|
|
24
35
|
onChange({ ...values, [field]: value });
|
|
25
36
|
};
|
|
@@ -32,7 +43,25 @@ export function SchemaForm({ schema, values, onChange, isLoading, className }: S
|
|
|
32
43
|
);
|
|
33
44
|
}
|
|
34
45
|
|
|
35
|
-
if (!schema) {
|
|
46
|
+
if (!fields && schema && !isHostSchema(schema)) {
|
|
47
|
+
return (
|
|
48
|
+
<div
|
|
49
|
+
role="alert"
|
|
50
|
+
data-testid="schema-form-outdated-schema"
|
|
51
|
+
className="text-center py-8 text-grey-04 dark:text-grey-07"
|
|
52
|
+
>
|
|
53
|
+
<p className="mb-2 font-medium text-grey-01 dark:text-grey-12">This form cannot be shown.</p>
|
|
54
|
+
<p>
|
|
55
|
+
This schema is out of date: it is not a generated host schema. Ask whoever maintains the site to declare it
|
|
56
|
+
with defineHostSchema and Typia, then rebuild the site.
|
|
57
|
+
</p>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const resolvedFields = fields ?? (schema ? fieldsOfHostSchema(schema) : null);
|
|
63
|
+
|
|
64
|
+
if (!resolvedFields) {
|
|
36
65
|
return (
|
|
37
66
|
<div className="text-center py-8 text-grey-04 dark:text-grey-07">
|
|
38
67
|
<p>No schema defined.</p>
|
|
@@ -40,12 +69,10 @@ export function SchemaForm({ schema, values, onChange, isLoading, className }: S
|
|
|
40
69
|
);
|
|
41
70
|
}
|
|
42
71
|
|
|
43
|
-
const fields = getZodShape(schema);
|
|
44
|
-
|
|
45
72
|
return (
|
|
46
73
|
<div className={className}>
|
|
47
74
|
<div className="space-y-6">
|
|
48
|
-
{Object.entries(
|
|
75
|
+
{Object.entries(resolvedFields).map(([fieldName, fieldInfo]) => (
|
|
49
76
|
// Names the field, so a dialog can open at it (see PageMetadataDialog's focusField).
|
|
50
77
|
<div key={fieldName} data-field-name={fieldName}>
|
|
51
78
|
<SchemaField
|
|
@@ -86,7 +113,9 @@ function SchemaField({ name, fieldInfo, value, onChange }: SchemaFieldProps) {
|
|
|
86
113
|
id={inputId}
|
|
87
114
|
type="datetime-local"
|
|
88
115
|
value={formatDateValue(value)}
|
|
89
|
-
|
|
116
|
+
// The input's wall-clock digits carry no zone or seconds; a host's `Format<'date-time'>`
|
|
117
|
+
// validator needs a full timestamp, so the value saved is the instant those digits name.
|
|
118
|
+
onChange={(e) => onChange(fromDatetimeLocalValue(e.target.value)?.toISOString())}
|
|
90
119
|
/>
|
|
91
120
|
{description && <p className="mt-1 text-sm text-grey-04 dark:text-grey-07">{description}</p>}
|
|
92
121
|
</div>
|
|
@@ -99,7 +99,9 @@ export function FolderTreeSidebar({ currentFolder, onFolderSelect, dropTargetFol
|
|
|
99
99
|
<button
|
|
100
100
|
type="button"
|
|
101
101
|
onClick={() => {
|
|
102
|
-
|
|
102
|
+
// Resetting an in-flight mutation detaches its success callback, so a reopened
|
|
103
|
+
// dialog would stay open with Create enabled after the folder was made.
|
|
104
|
+
if (!createFolder.isPending) createFolder.reset();
|
|
103
105
|
setShowCreateFolderDialog(true);
|
|
104
106
|
}}
|
|
105
107
|
className="p-1.5 rounded-md hover:bg-grey-11 dark:hover:bg-grey-03 transition-colors"
|
|
@@ -48,6 +48,9 @@ export function DataList({ dataSchemas }: DataListProps) {
|
|
|
48
48
|
|
|
49
49
|
// Get config for editor links
|
|
50
50
|
const config = getUIConfig();
|
|
51
|
+
// A page reads the data entries of its own language only: create one in the language the editor
|
|
52
|
+
// offers first, as a new page or fragment is.
|
|
53
|
+
const newEntryLocale = config.locales?.defaultLocale ?? config.locales?.list[0] ?? 'en';
|
|
51
54
|
const schemasEditorLink =
|
|
52
55
|
config.projectRoot && config.schemasPath ? getSchemasEditorLink(config.projectRoot, config.schemasPath) : null;
|
|
53
56
|
const [deleteDialog, openDeleteDialog, closeDeleteDialog] = useDialogState({
|
|
@@ -188,9 +191,8 @@ export function DataList({ dataSchemas }: DataListProps) {
|
|
|
188
191
|
title,
|
|
189
192
|
description,
|
|
190
193
|
},
|
|
191
|
-
// Use 'en' as the default locale for new data entries
|
|
192
194
|
locales: {
|
|
193
|
-
|
|
195
|
+
[newEntryLocale]: {
|
|
194
196
|
meta: {
|
|
195
197
|
title,
|
|
196
198
|
description,
|
|
@@ -226,8 +228,8 @@ export function DataList({ dataSchemas }: DataListProps) {
|
|
|
226
228
|
entryId: result.id,
|
|
227
229
|
entryTitle: title,
|
|
228
230
|
collection,
|
|
229
|
-
locale:
|
|
230
|
-
existingLocales: [
|
|
231
|
+
locale: newEntryLocale,
|
|
232
|
+
existingLocales: [newEntryLocale],
|
|
231
233
|
name,
|
|
232
234
|
});
|
|
233
235
|
} else if (!result.success) {
|