@wordpress/blocks
Version:
Block API for WordPress.
75 lines • 2.37 kB
TypeScript
/**
* A representation of a block's rich text value.
*/
export type BlockChildren = Array<string | Record<string, unknown>>;
/**
* Given block children, returns a serialize-capable WordPress element.
*
* @param children Block children object to convert.
*
* @return A serialize-capable element.
*/
export declare function getSerializeCapableElement(children: BlockChildren): BlockChildren;
/**
* Given block children, returns an array of block nodes.
*
* @param children Block children object to convert.
*
* @return An array of individual block nodes.
*/
declare function getChildrenArray(children: BlockChildren): BlockChildren;
/**
* Given two or more block nodes, returns a new block node representing a
* concatenation of its values.
*
* @param blockNodes Block nodes to concatenate.
*
* @return Concatenated block node.
*/
export declare function concat(...blockNodes: Array<BlockChildren | string>): BlockChildren;
/**
* Given an iterable set of DOM nodes, returns equivalent block children.
* Ignores any non-element/text nodes included in set.
*
* @param domNodes Iterable set of DOM nodes to convert.
*
* @return Block children equivalent to DOM nodes.
*/
export declare function fromDOM(domNodes: NodeListOf<ChildNode> | NodeList): BlockChildren;
/**
* Given a block node, returns its HTML string representation.
*
* @param children Block node(s) to convert to string.
*
* @return String HTML representation of block node.
*/
export declare function toHTML(children: BlockChildren): string;
/**
* Given a selector, returns an hpq matcher generating a BlockChildren value
* matching the selector result.
*
* @param selector DOM selector.
*
* @return hpq matcher.
*/
export declare function matcher(selector?: string): (domNode: Element) => BlockChildren;
/**
* Object of utility functions used in managing block attribute values of
* source `children`.
*
* @see https://github.com/WordPress/gutenberg/pull/10439
*
* @deprecated since 4.0. The `children` source should not be used, and can be
* replaced by the `html` source.
*
* @private
*/
declare const _default: {
concat: typeof concat;
getChildrenArray: typeof getChildrenArray;
fromDOM: typeof fromDOM;
toHTML: typeof toHTML;
matcher: typeof matcher;
};
export default _default;
//# sourceMappingURL=children.d.ts.map