@dotcms/react
Version:
Official React Components library to render a dotCMS page.
55 lines (54 loc) • 2.1 kB
TypeScript
import { BlockEditorNode } from '@dotcms/types';
/**
* Props that all custom renderers must accept.
*
* @export
* @interface CustomRendererProps
* @template TData - The type of data stored in node.attrs.data (for contentlet blocks)
*/
export interface CustomRendererProps<TData = any> {
/** The full BlockEditorNode with attrs, marks, content, etc. */
node: BlockEditorNode & {
attrs?: {
data?: TData;
[key: string]: any;
};
};
/** Rendered children from nested content (if any) */
children?: React.ReactNode;
}
/**
* Custom renderer component type - must accept node and optional children.
* Can be specialized with a specific data type for node.attrs.data.
*
* @export
* @template TData - The type of contentlet data in node.attrs.data
*/
export type CustomRendererComponent<TData = any> = React.FC<CustomRendererProps<TData>>;
/**
* Map of block type names to custom renderer components.
* Use the generic parameter to type specific contentlet data.
*
* @export
* @interface CustomRenderer
*/
export type CustomRenderer = Record<string, CustomRendererComponent<any>>;
export interface BlockEditorRendererProps {
blocks: BlockEditorNode;
style?: React.CSSProperties;
className?: string;
customRenderers?: CustomRenderer;
isDevMode?: boolean;
}
/**
* BlockEditorRenderer component for rendering block editor field.
*
* @component
* @param {Object} props - The component props.
* @param {BlockEditorNode} props.blocks - The blocks of content to render.
* @param {CustomRenderer} [props.customRenderers] - Optional custom renderers for specific block types.
* @param {string} [props.className] - Optional CSS class name for the container div.
* @param {React.CSSProperties} [props.style] - Optional inline styles for the container div.
* @returns {JSX.Element} A div containing the rendered blocks of content.
*/
export declare const DotCMSBlockEditorRenderer: ({ blocks, style, className, customRenderers, isDevMode }: BlockEditorRendererProps) => import("react/jsx-runtime").JSX.Element | null;