@wordpress/blocks
Version:
Block API for WordPress.
27 lines • 1.08 kB
TypeScript
import type { Block } from '../types';
type TemplateItem = [string, Record<string, unknown>?, TemplateItem[]?];
/**
* Checks whether a list of blocks matches a template by comparing the block names.
*
* @param blocks Block list.
* @param template Block template.
*
* @return Whether the list of blocks matches a templates.
*/
export declare function doBlocksMatchTemplate(blocks?: Block[], template?: TemplateItem[]): boolean;
/**
* Synchronize a block list with a block template.
*
* Synchronizing a block list with a block template means that we loop over the blocks
* keep the block as is if it matches the block at the same position in the template
* (If it has the same name) and if doesn't match, we create a new block based on the template.
* Extra blocks not present in the template are removed.
*
* @param blocks Block list.
* @param template Block template.
*
* @return Updated Block list.
*/
export declare function synchronizeBlocksWithTemplate(blocks?: Block[], template?: TemplateItem[]): Block[];
export {};
//# sourceMappingURL=templates.d.ts.map