@wordpress/blocks
Version:
Block API for WordPress.
117 lines • 4.42 kB
TypeScript
import type { Block, BlockType, BlockSerializationOptions } from '../types';
/**
* Returns the block's default classname from its name.
*
* @param blockName The block name.
*
* @return The block's default class.
*/
export declare function getBlockDefaultClassName(blockName: string): string;
/**
* Returns the block's default menu item classname from its name.
*
* @param blockName The block name.
*
* @return The block's default menu item class.
*/
export declare function getBlockMenuDefaultClassName(blockName: string): string;
/**
* Call within a save function to get the props for the block wrapper.
*
* @param props Optional. Props to pass to the element.
*/
export declare function getBlockProps(props?: Record<string, unknown>): Record<string, unknown>;
/**
* Call within a save function to get the props for the inner blocks wrapper.
*
* @param props Optional. Props to pass to the element.
*/
export declare function getInnerBlocksProps(props?: Record<string, unknown>): Record<string, unknown>;
/**
* Given a block type containing a save render implementation and attributes, returns the
* enhanced element to be saved or string when raw HTML expected.
*
* @param blockTypeOrName Block type or name.
* @param attributes Block attributes.
* @param innerBlocks Nested blocks.
*
* @return Save element or raw HTML string.
*/
export declare function getSaveElement(blockTypeOrName: string | BlockType, attributes: Record<string, unknown>, innerBlocks?: Block[]): unknown;
/**
* Given a block type containing a save render implementation and attributes, returns the
* static markup to be saved.
*
* @param blockTypeOrName Block type or name.
* @param attributes Block attributes.
* @param innerBlocks Nested blocks.
*
* @return Save content.
*/
export declare function getSaveContent(blockTypeOrName: string | BlockType | undefined | null, attributes: Record<string, unknown>, innerBlocks?: Block[]): string;
/**
* Returns attributes which are to be saved and serialized into the block
* comment delimiter.
*
* When a block exists in memory it contains as its attributes both those
* parsed the block comment delimiter _and_ those which matched from the
* contents of the block.
*
* This function returns only those attributes which are needed to persist and
* which cannot be matched from the block content.
*
* @param blockType Block type.
* @param attributes Attributes from in-memory block data.
*
* @return Subset of attributes for comment serialization.
*/
export declare function getCommentAttributes(blockType: BlockType, attributes: Record<string, unknown>): Record<string, unknown>;
/**
* Given an attributes object, returns a string in the serialized attributes
* format prepared for post content.
*
* @param attributes Attributes object.
*
* @return Serialized attributes.
*/
export declare function serializeAttributes(attributes: Record<string, unknown>): string;
/**
* Given a block object, returns the Block's Inner HTML markup.
*
* @param block Block instance.
*
* @return HTML.
*/
export declare function getBlockInnerHTML(block: Block): string;
/**
* Returns the content of a block, including comment delimiters.
*
* @param rawBlockName Block name.
* @param attributes Block attributes.
* @param content Block save content.
*
* @return Comment-delimited block content.
*/
export declare function getCommentDelimitedContent(rawBlockName: string | undefined, attributes: Record<string, unknown> | null, content: string): string;
/**
* Returns the content of a block, including comment delimiters, determining
* serialized attributes and content form from the current state of the block.
*
* @param block Block instance.
* @param options Serialization options.
*
* @param options.isInnerBlocks
* @return Serialized block.
*/
export declare function serializeBlock(block: Block, { isInnerBlocks }?: BlockSerializationOptions): string;
export declare const __unstableSerializeAndClean: (blocks: Block[]) => string;
/**
* Takes a block or set of blocks and returns the serialized post content.
*
* @param blocks Block(s) to serialize.
* @param options Serialization options.
*
* @return The post content.
*/
export default function serialize(blocks: Block | Block[], options?: BlockSerializationOptions): string;
//# sourceMappingURL=serializer.d.ts.map