@dotcms/react 1.1.1-next.3 → 1.1.1-next.5
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/index.esm.js
CHANGED
|
@@ -5141,7 +5141,7 @@ const DotContent = ({
|
|
|
5141
5141
|
const {
|
|
5142
5142
|
contentType = 'Unknown Content Type'
|
|
5143
5143
|
} = data;
|
|
5144
|
-
const Component = customRenderers[contentType];
|
|
5144
|
+
const Component = customRenderers == null ? void 0 : customRenderers[contentType];
|
|
5145
5145
|
/* In dev mode, show a helpful message for unknown content types */
|
|
5146
5146
|
if (isDevMode && !Component) {
|
|
5147
5147
|
return jsx(NoComponentProvided, {
|
|
@@ -5153,7 +5153,9 @@ const DotContent = ({
|
|
|
5153
5153
|
console.warn(DOT_CONTENT_NO_MATCHING_COMPONENT_MESSAGE(contentType));
|
|
5154
5154
|
return null;
|
|
5155
5155
|
}
|
|
5156
|
-
return jsx(Component,
|
|
5156
|
+
return jsx(Component, {
|
|
5157
|
+
node: node
|
|
5158
|
+
});
|
|
5157
5159
|
};
|
|
5158
5160
|
|
|
5159
5161
|
/**
|
|
@@ -5478,7 +5480,7 @@ const BlockEditorBlock = ({
|
|
|
5478
5480
|
const key = `${node.type}-${index}`;
|
|
5479
5481
|
if (CustomRendererComponent) {
|
|
5480
5482
|
return jsx(CustomRendererComponent, {
|
|
5481
|
-
|
|
5483
|
+
node: node,
|
|
5482
5484
|
children: jsx(BlockEditorBlock, {
|
|
5483
5485
|
content: node.content,
|
|
5484
5486
|
customRenderers: customRenderers
|
|
@@ -5613,7 +5615,7 @@ const UnknownBlock = ({
|
|
|
5613
5615
|
*
|
|
5614
5616
|
* @component
|
|
5615
5617
|
* @param {Object} props - The component props.
|
|
5616
|
-
* @param {
|
|
5618
|
+
* @param {BlockEditorNode} props.blocks - The blocks of content to render.
|
|
5617
5619
|
* @param {CustomRenderer} [props.customRenderers] - Optional custom renderers for specific block types.
|
|
5618
5620
|
* @param {string} [props.className] - Optional CSS class name for the container div.
|
|
5619
5621
|
* @param {React.CSSProperties} [props.style] - Optional inline styles for the container div.
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export { DotCMSShow } from './lib/next/components/DotCMSShow/DotCMSShow';
|
|
|
3
3
|
export { useDotCMSShowWhen } from './lib/next/hooks/useDotCMSShowWhen';
|
|
4
4
|
export { useEditableDotCMSPage } from './lib/next/hooks/useEditableDotCMSPage';
|
|
5
5
|
export { DotCMSEditableText } from './lib/next/components/DotCMSEditableText/DotCMSEditableText';
|
|
6
|
-
export { DotCMSBlockEditorRenderer, BlockEditorRendererProps } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer';
|
|
6
|
+
export { DotCMSBlockEditorRenderer, BlockEditorRendererProps, CustomRenderer, CustomRendererProps } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer';
|
|
7
7
|
export { DotCMSLayoutBodyProps } from './lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody';
|
|
@@ -1,13 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockEditorNode } from '@dotcms/types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Props that all custom renderers must accept.
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @interface CustomRendererProps
|
|
7
|
+
* @template TData - The type of data stored in node.attrs.data (for contentlet blocks)
|
|
8
|
+
*/
|
|
9
|
+
export interface CustomRendererProps<TData = any> {
|
|
10
|
+
/** The full BlockEditorNode with attrs, marks, content, etc. */
|
|
11
|
+
node: BlockEditorNode & {
|
|
12
|
+
attrs?: {
|
|
13
|
+
data?: TData;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/** Rendered children from nested content (if any) */
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Custom renderer component type - must accept node and optional children.
|
|
22
|
+
* Can be specialized with a specific data type for node.attrs.data.
|
|
23
|
+
*
|
|
24
|
+
* @export
|
|
25
|
+
* @template TData - The type of contentlet data in node.attrs.data
|
|
26
|
+
*/
|
|
27
|
+
export type CustomRendererComponent<TData = any> = React.FC<CustomRendererProps<TData>>;
|
|
28
|
+
/**
|
|
29
|
+
* Map of block type names to custom renderer components.
|
|
30
|
+
* Use the generic parameter to type specific contentlet data.
|
|
4
31
|
*
|
|
5
32
|
* @export
|
|
6
33
|
* @interface CustomRenderer
|
|
7
34
|
*/
|
|
8
|
-
export type CustomRenderer
|
|
35
|
+
export type CustomRenderer = Record<string, CustomRendererComponent<any>>;
|
|
9
36
|
export interface BlockEditorRendererProps {
|
|
10
|
-
blocks:
|
|
37
|
+
blocks: BlockEditorNode;
|
|
11
38
|
style?: React.CSSProperties;
|
|
12
39
|
className?: string;
|
|
13
40
|
customRenderers?: CustomRenderer;
|
|
@@ -17,7 +44,7 @@ export interface BlockEditorRendererProps {
|
|
|
17
44
|
*
|
|
18
45
|
* @component
|
|
19
46
|
* @param {Object} props - The component props.
|
|
20
|
-
* @param {
|
|
47
|
+
* @param {BlockEditorNode} props.blocks - The blocks of content to render.
|
|
21
48
|
* @param {CustomRenderer} [props.customRenderers] - Optional custom renderers for specific block types.
|
|
22
49
|
* @param {string} [props.className] - Optional CSS class name for the container div.
|
|
23
50
|
* @param {React.CSSProperties} [props.style] - Optional inline styles for the container div.
|