@dotcms/react
Version:
Official React Components library to render a dotCMS page.
59 lines (58 loc) • 2.19 kB
TypeScript
import { ContainerData, DotCMSPageContext } from '../models';
import { Block, BlockEditorState } from '../models/blocks.interface';
/**
* Get the container data from the containers object using the current container reference obtained from the layout.
*
* @param {ContainerData} containers
* @param {DotCMSPageContext['pageAsset']['layout']['body']['rows'][0]['columns'][0]['containers'][0]} containerRef
* @returns {Object} Container with all the data it has.
*/
export declare const getContainersData: (containers: ContainerData, containerRef: DotCMSPageContext['pageAsset']['layout']['body']['rows'][0]['columns'][0]['containers'][0]) => {
acceptTypes: string;
contentlets: {
contentType: string;
identifier: string;
title: string;
inode: string;
onNumberOfPages: number;
widgetTitle?: string | undefined;
baseType: string;
}[];
variantId: string;
path: string;
identifier: string;
maxContentlets: number;
parentPermissionable: Record<string, string>;
};
/**
* Combine classes into a single string.
*
* @param {string[]} classes
* @returns {string} Combined classes
*/
export declare const combineClasses: (classes: string[]) => string;
/**
* Get the start and end classes for the column based on the left offset and width.
*
* @param {number} start
* @param {number} end
* @returns {Object} Start and end classes
*/
export declare const getPositionStyleClasses: (start: number, end: number) => {
startClass: string;
endClass: string;
};
/**
* Validates the structure of a Block Editor block.
*
* This function checks that:
* 1. The blocks parameter is a valid object
* 2. The block has a 'doc' type
* 3. The block has a valid content array that is not empty
*
* @param {Block} blocks - The blocks structure to validate
* @returns {BlockEditorState} Object containing validation state and any error message
* @property {boolean} BlockEditorState.isValid - Whether the blocks structure is valid
* @property {string | null} BlockEditorState.error - Error message if invalid, null if valid
*/
export declare const isValidBlocks: (blocks: Block) => BlockEditorState;