@dotcms/react 26.8.3-1-next.2478 → 26.8.3-1-next.2490
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/lib/next/components/Container/Container.esm.js +5 -2
- package/lib/next/contexts/DotCMSPageContext.esm.js +1 -1
- package/lib/next/hooks/useEditableDotCMSPage.esm.js +18 -12
- package/package.json +3 -3
- package/src/lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.d.ts +6 -1
- package/src/lib/next/components/DotCMSLayoutBody/DotCMSPageProvider.d.ts +1 -1
- package/src/lib/next/contexts/DotCMSPageContext.d.ts +5 -1
- package/src/lib/next/hooks/useEditableDotCMSPage.d.ts +8 -3
|
@@ -33,8 +33,11 @@ function Container({
|
|
|
33
33
|
pageAsset
|
|
34
34
|
} = useContext(DotCMSPageContext);
|
|
35
35
|
const isDevMode = useIsDevMode();
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
// pageAsset is undefined while useEditableDotCMSPage is still waiting on the UVE editor to
|
|
37
|
+
// resolve a draft/non-live page - Container never actually renders in that state (its parent
|
|
38
|
+
// DotCMSLayoutBody shows ErrorMessage instead), but the guard keeps this honest either way.
|
|
39
|
+
const containerData = useMemo(() => pageAsset ? getContainersData(pageAsset, container) : null, [pageAsset, container]);
|
|
40
|
+
const contentlets = useMemo(() => pageAsset ? getContentletsInContainer(pageAsset, container) : [], [pageAsset, container]);
|
|
38
41
|
if (!containerData) {
|
|
39
42
|
return jsx(ContainerNotFound, {
|
|
40
43
|
identifier: container.identifier
|
|
@@ -86,28 +86,34 @@ import { registerStyleEditorSchemas } from '@dotcms/uve/internal';
|
|
|
86
86
|
* </div>
|
|
87
87
|
* );
|
|
88
88
|
* ```
|
|
89
|
-
* @param {DotCMSPageResponse} pageResponse - The
|
|
89
|
+
* @param {DotCMSPageResponse | Pick<DotCMSPageResponse, 'graphql'>} [pageResponse] - The page data
|
|
90
|
+
* from client.page.get(). If that call threw (draft/non-live page, permissions), pass
|
|
91
|
+
* `{ graphql: error.graphql }` instead — `DotErrorPage` always carries the GraphQL query it
|
|
92
|
+
* attempted, even on failure. Forwarding it here lets the editor retry the fetch with edit-mode
|
|
93
|
+
* permissions and deliver the real content via `postMessage`; pass `undefined` and there's nothing
|
|
94
|
+
* for the editor to retry.
|
|
90
95
|
*
|
|
91
96
|
* @returns {DotCMSPageResponse} The updated editable page state that reflects any changes made in the UVE.
|
|
92
97
|
* The structure includes page data and any GraphQL content that was requested.
|
|
93
98
|
*/
|
|
94
99
|
const useEditableDotCMSPage = pageResponse => {
|
|
95
|
-
const
|
|
100
|
+
const pageData = pageResponse && 'pageAsset' in pageResponse ? pageResponse : undefined;
|
|
101
|
+
const [updatedPageResponse, setUpdatedPageResponse] = useState(pageData);
|
|
96
102
|
useEffect(() => {
|
|
97
|
-
var
|
|
103
|
+
var _pageData$pageAsset, _pageData$styleEditor;
|
|
98
104
|
if (!getUVEState()) {
|
|
99
105
|
// Outside UVE, state only ever comes from props - keep it in sync with
|
|
100
106
|
// whatever pageResponse the parent re-renders with (e.g. after a client-side
|
|
101
107
|
// navigation refetches page data), since the initial useState value above is
|
|
102
108
|
// otherwise frozen after the first render.
|
|
103
|
-
setUpdatedPageResponse(
|
|
109
|
+
setUpdatedPageResponse(pageData);
|
|
104
110
|
return;
|
|
105
111
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const pageURI =
|
|
112
|
+
// Inside UVE, pageResponse can be undefined, or just `{ graphql }` (e.g. a draft/non-live
|
|
113
|
+
// page the customer's own fetch treated as a 404, but still knows the GraphQL query it
|
|
114
|
+
// attempted) - forward it to initUVE either way so the editor has something to retry with
|
|
115
|
+
// edit-mode permissions. Without a query to retry, CONTENT_CHANGES never arrives.
|
|
116
|
+
const pageURI = pageData == null || (_pageData$pageAsset = pageData.pageAsset) == null || (_pageData$pageAsset = _pageData$pageAsset.page) == null ? void 0 : _pageData$pageAsset.pageURI;
|
|
111
117
|
const {
|
|
112
118
|
destroyUVESubscriptions
|
|
113
119
|
} = initUVE(pageResponse);
|
|
@@ -117,13 +123,13 @@ const useEditableDotCMSPage = pageResponse => {
|
|
|
117
123
|
if (pageURI) {
|
|
118
124
|
updateNavigation(pageURI);
|
|
119
125
|
}
|
|
120
|
-
if ((
|
|
121
|
-
registerStyleEditorSchemas(
|
|
126
|
+
if (pageData != null && (_pageData$styleEditor = pageData.styleEditorSchemas) != null && _pageData$styleEditor.length) {
|
|
127
|
+
registerStyleEditorSchemas(pageData.styleEditorSchemas);
|
|
122
128
|
}
|
|
123
129
|
return () => {
|
|
124
130
|
destroyUVESubscriptions();
|
|
125
131
|
};
|
|
126
|
-
}, [pageResponse]);
|
|
132
|
+
}, [pageResponse, pageData]);
|
|
127
133
|
useEffect(() => {
|
|
128
134
|
const {
|
|
129
135
|
unsubscribe
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/react",
|
|
3
|
-
"version": "26.8.3-1-next.
|
|
3
|
+
"version": "26.8.3-1-next.2490",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=18",
|
|
6
6
|
"react-dom": ">=18"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@dotcms/uve": "26.8.3-1-next.
|
|
10
|
-
"@dotcms/client": "26.8.3-1-next.
|
|
9
|
+
"@dotcms/uve": "26.8.3-1-next.2490",
|
|
10
|
+
"@dotcms/client": "26.8.3-1-next.2490",
|
|
11
11
|
"@tinymce/tinymce-react": "6.2.1"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { DotCMSBasicContentlet, DotCMSPageAsset, DotCMSPageRendererMode } from '@dotcms/types';
|
|
3
3
|
export interface DotCMSLayoutBodyProps<TContentlet extends DotCMSBasicContentlet = DotCMSBasicContentlet> {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The DotCMS page asset. Can be `undefined` while `useEditableDotCMSPage` is still waiting
|
|
6
|
+
* on the UVE editor to resolve a draft/non-live page — the component renders `ErrorMessage`
|
|
7
|
+
* until it arrives.
|
|
8
|
+
*/
|
|
9
|
+
page: DotCMSPageAsset | undefined;
|
|
5
10
|
components: {
|
|
6
11
|
[key: string]: React.ComponentType<TContentlet> | React.ComponentType<any>;
|
|
7
12
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { DotCMSPageAsset, DotCMSPageRendererMode } from '@dotcms/types';
|
|
3
3
|
interface DotCMSPageProviderProps {
|
|
4
|
-
page: DotCMSPageAsset;
|
|
4
|
+
page: DotCMSPageAsset | undefined;
|
|
5
5
|
components: Record<string, React.ComponentType<any>>;
|
|
6
6
|
mode: DotCMSPageRendererMode;
|
|
7
7
|
slots?: Record<string, ReactNode>;
|
|
@@ -11,7 +11,11 @@ import { DotCMSBasicContentlet, DotCMSPageAsset, DotCMSPageRendererMode } from '
|
|
|
11
11
|
* @property {Record<string, ReactNode>} [slots] - Pre-rendered server component nodes keyed by contentlet identifier
|
|
12
12
|
*/
|
|
13
13
|
export interface DotCMSPageContextProps {
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Can be `undefined` while `useEditableDotCMSPage` is still waiting on the UVE editor to
|
|
16
|
+
* resolve a draft/non-live page, or when permissions leave it unset outside the editor.
|
|
17
|
+
*/
|
|
18
|
+
pageAsset: DotCMSPageAsset | undefined;
|
|
15
19
|
mode: DotCMSPageRendererMode;
|
|
16
20
|
userComponents: Record<string, React.ComponentType<DotCMSBasicContentlet>>;
|
|
17
21
|
slots?: Record<string, ReactNode>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DotCMSComposedPageResponse, DotCMSExtendedPageResponse } from '@dotcms/types';
|
|
1
|
+
import { DotCMSComposedPageResponse, DotCMSPageResponse, DotCMSExtendedPageResponse } from '@dotcms/types';
|
|
2
2
|
/**
|
|
3
3
|
* Custom hook to manage the editable state of a DotCMS page.
|
|
4
4
|
*
|
|
@@ -82,9 +82,14 @@ import { DotCMSComposedPageResponse, DotCMSExtendedPageResponse } from '@dotcms/
|
|
|
82
82
|
* </div>
|
|
83
83
|
* );
|
|
84
84
|
* ```
|
|
85
|
-
* @param {DotCMSPageResponse} pageResponse - The
|
|
85
|
+
* @param {DotCMSPageResponse | Pick<DotCMSPageResponse, 'graphql'>} [pageResponse] - The page data
|
|
86
|
+
* from client.page.get(). If that call threw (draft/non-live page, permissions), pass
|
|
87
|
+
* `{ graphql: error.graphql }` instead — `DotErrorPage` always carries the GraphQL query it
|
|
88
|
+
* attempted, even on failure. Forwarding it here lets the editor retry the fetch with edit-mode
|
|
89
|
+
* permissions and deliver the real content via `postMessage`; pass `undefined` and there's nothing
|
|
90
|
+
* for the editor to retry.
|
|
86
91
|
*
|
|
87
92
|
* @returns {DotCMSPageResponse} The updated editable page state that reflects any changes made in the UVE.
|
|
88
93
|
* The structure includes page data and any GraphQL content that was requested.
|
|
89
94
|
*/
|
|
90
|
-
export declare const useEditableDotCMSPage: <T extends DotCMSExtendedPageResponse>(pageResponse: DotCMSComposedPageResponse<T>) => DotCMSComposedPageResponse<T
|
|
95
|
+
export declare const useEditableDotCMSPage: <T extends DotCMSExtendedPageResponse>(pageResponse: DotCMSComposedPageResponse<T> | Pick<DotCMSPageResponse, "graphql"> | undefined) => DotCMSComposedPageResponse<T> | undefined;
|