@wordpress/block-library
Version:
Block library for the WordPress editor.
35 lines • 1.24 kB
TypeScript
import type { Block } from '@wordpress/blocks';
export interface HeadingData {
/** The plain text content of the heading. */
content: string;
/** The heading level. */
level: number;
/** Link to the heading. */
link: string;
}
export interface NestedHeadingData {
/** The heading content, level, and link. */
heading: HeadingData;
/** The sub-headings of this heading, if any. */
children: NestedHeadingData[] | null;
}
/**
* Takes a flat list of heading parameters and nests them based on each header's
* immediate parent's level.
*
* @param headingList The flat list of headings to nest.
*
* @return The nested list of headings.
*/
export declare function linearToNestedHeadingList(headingList: HeadingData[]): NestedHeadingData[];
/**
* Converts a nested heading list into `core/list-item` blocks, with
* sub-headings nested in a `core/list` block inside their parent item.
*
* @param nestedHeadingList The nested list of headings.
* @param ordered Whether nested lists are ordered.
*
* @return The list item blocks.
*/
export declare function createListItemBlocks(nestedHeadingList: NestedHeadingData[], ordered: boolean): Block[];
//# sourceMappingURL=utils.d.ts.map