@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, Object.assign({}, node));
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
- content: node.content,
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 {BlockEditorContent} props.blocks - The blocks of content to render.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/react",
3
- "version": "1.1.1-next.3",
3
+ "version": "1.1.1-next.5",
4
4
  "peerDependencies": {
5
5
  "react": ">=18",
6
6
  "react-dom": ">=18"
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 { BlockEditorContent } from '@dotcms/types';
1
+ import { BlockEditorNode } from '@dotcms/types';
2
2
  /**
3
- * Represents a Custom Renderer used by the Block Editor Component
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<T = any> = Record<string, React.FC<T>>;
35
+ export type CustomRenderer = Record<string, CustomRendererComponent<any>>;
9
36
  export interface BlockEditorRendererProps {
10
- blocks: BlockEditorContent;
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 {BlockEditorContent} props.blocks - The blocks of content to render.
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.
@@ -1,7 +1,7 @@
1
1
  import { BlockEditorNode } from '@dotcms/types';
2
2
  import { CustomRenderer } from '../../DotCMSBlockEditorRenderer';
3
3
  interface DotContentProps {
4
- customRenderers: CustomRenderer;
4
+ customRenderers?: CustomRenderer;
5
5
  node: BlockEditorNode;
6
6
  }
7
7
  /**