@dotcms/client
Version:
Official JavaScript library for interacting with DotCMS REST APIs.
160 lines (159 loc) • 5.43 kB
TypeScript
/**
* Bound information for a contentlet.
*
* @interface ContentletBound
* @property {number} x - The x-coordinate of the contentlet.
* @property {number} y - The y-coordinate of the contentlet.
* @property {number} width - The width of the contentlet.
* @property {number} height - The height of the contentlet.
* @property {string} payload - The payload data of the contentlet in JSON format.
*/
interface ContentletBound {
x: number;
y: number;
width: number;
height: number;
payload: string;
}
/**
* Bound information for a container.
*
* @interface ContainerBound
* @property {number} x - The x-coordinate of the container.
* @property {number} y - The y-coordinate of the container.
* @property {number} width - The width of the container.
* @property {number} height - The height of the container.
* @property {string} payload - The payload data of the container in JSON format.
* @property {ContentletBound[]} contentlets - An array of contentlets within the container.
*/
interface ContainerBound {
x: number;
y: number;
width: number;
height: number;
payload: string;
contentlets: ContentletBound[];
}
/**
* Calculates the bounding information for each page element within the given containers.
*
* @export
* @param {HTMLDivElement[]} containers - An array of HTMLDivElement representing the containers.
* @return {ContainerBound[]} An array of objects containing the bounding information for each page element.
* @example
* ```ts
* const containers = document.querySelectorAll('.container');
* const bounds = getPageElementBound(containers);
* console.log(bounds);
* ```
*/
export declare function getPageElementBound(containers: HTMLDivElement[]): ContainerBound[];
/**
* Calculates the bounding information for each contentlet inside a container.
*
* @export
* @param {DOMRect} containerRect - The bounding rectangle of the container.
* @param {HTMLDivElement[]} contentlets - An array of HTMLDivElement representing the contentlets.
* @return {ContentletBound[]} An array of objects containing the bounding information for each contentlet.
* @example
* ```ts
* const containerRect = container.getBoundingClientRect();
* const contentlets = container.querySelectorAll('.contentlet');
* const bounds = getContentletsBound(containerRect, contentlets);
* console.log(bounds); // Element bounds within the container
* ```
*/
export declare function getContentletsBound(containerRect: DOMRect, contentlets: HTMLDivElement[]): ContentletBound[];
/**
* Get container data from VTLS.
*
* @export
* @param {HTMLElement} container - The container element.
* @return {object} An object containing the container data.
* @example
* ```ts
* const container = document.querySelector('.container');
* const data = getContainerData(container);
* console.log(data);
* ```
*/
export declare function getContainerData(container: HTMLElement): {
acceptTypes: string;
identifier: string;
maxContentlets: string;
uuid: string;
};
/**
* Get the closest container data from the contentlet.
*
* @export
* @param {Element} element - The contentlet element.
* @return {object | null} An object containing the closest container data or null if no container is found.
* @example
* ```ts
* const contentlet = document.querySelector('.contentlet');
* const data = getClosestContainerData(contentlet);
* console.log(data);
* ```
*/
export declare function getClosestContainerData(element: Element): {
acceptTypes: string;
identifier: string;
maxContentlets: string;
uuid: string;
} | null;
/**
* Find the closest contentlet element based on HTMLElement.
*
* @export
* @param {HTMLElement | null} element - The starting element.
* @return {HTMLElement | null} The closest contentlet element or null if not found.
* @example
* const element = document.querySelector('.some-element');
* const contentlet = findDotElement(element);
* console.log(contentlet);
*/
export declare function findDotElement(element: HTMLElement | null): HTMLElement | null;
/**
* Find the closest VTL file element based on HTMLElement.
*
* @export
* @param {HTMLElement | null} element - The starting element.
* @return {HTMLElement | null} The closest VTL file element or null if not found.
* @example
* const element = document.querySelector('.some-element');
* const vtlFile = findDotVTLElement(element);
* console.log(vtlFile);
*/
export declare function findDotVTLElement(element: HTMLElement | null): HTMLElement | null;
/**
* Find VTL data within a target element.
*
* @export
* @param {HTMLElement} target - The target element to search within.
* @return {Array<{ inode: string, name: string }> | null} An array of objects containing VTL data or null if none found.
* @example
* ```ts
* const target = document.querySelector('.target-element');
* const vtlData = findVTLData(target);
* console.log(vtlData);
* ```
*/
export declare function findVTLData(target: HTMLElement): {
inode: string | undefined;
name: string | undefined;
}[] | null;
/**
* Check if the scroll position is at the bottom of the page.
*
* @export
* @return {boolean} True if the scroll position is at the bottom, otherwise false.
* @example
* ```ts
* if (scrollIsInBottom()) {
* console.log('Scrolled to the bottom');
* }
* ```
*/
export declare function scrollIsInBottom(): boolean;
export {};