How to use the @wordpress/blocks.parseWithAttributeSchema function in @wordpress/blocks

To help you get started, we’ve selected a few @wordpress/blocks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / wordpress__blocks / wordpress__blocks-tests.tsx View on Github external
// $ExpectType string | undefined
blocks.parseWithAttributeSchema(TEST_HTML, {
    source: 'html',
    selector: '#root',
});

// $ExpectType string | undefined
blocks.parseWithAttributeSchema(TEST_HTML, {
    source: 'html',
    selector: '#root',
    multiline: 'p',
});

// $ExpectType string | undefined
blocks.parseWithAttributeSchema(TEST_HTML, {
    source: 'text',
    selector: '#root',
});

// $ExpectType ReactChild[]
blocks.parseWithAttributeSchema(TEST_HTML, {
    source: 'children',
    selector: '#root',
});

// $ExpectType ReactChild[]
blocks.parseWithAttributeSchema(TEST_HTML, {
    source: 'children',
});

blocks.parseWithAttributeSchema(TEST_HTML, {
github Automattic / wp-calypso / client / gutenberg / editor / media-utils.js View on Github external
export const mediaCalypsoToGutenberg = media => {
	return {
		id: get( media, 'ID' ),
		url: get( media, 'URL' ),
		alt: get( media, 'alt' ),
		// TODO: replace with `{ source: 'rich-text' }` after updating Gutenberg
		caption: !! media.caption
			? parseWithAttributeSchema( media.caption, { source: 'children' } )
			: '',
		description: get( media, 'description' ),
		filename: get( media, 'file' ),
		height: get( media, 'height' ),
		icon: get( media, 'icon' ),
		mime: get( media, 'mime_type' ),
		sizes: {
			full: {
				url: get( media, 'URL' ),
			},
			...reduce(
				media.thumbnails,
				( thumbnails, url, size ) => {
					thumbnails[ size ] = { url };
					return thumbnails;
				},
github WordPress / gutenberg / packages / block-editor / src / hooks / custom-class-name.native.js View on Github external
export function getHTMLRootElementClasses( innerHTML ) {
	innerHTML = `<div data-custom-class-name="">${ innerHTML }</div>`;

	const parsed = parseWithAttributeSchema( innerHTML, {
		type: 'string',
		source: 'attribute',
		selector: '[data-custom-class-name] &gt; *',
		attribute: 'class',
	} );

	return parsed ? parsed.trim().split( /\s+/ ) : [];
}
github WordPress / gutenberg / packages / block-editor / src / hooks / custom-class-name.js View on Github external
export function getHTMLRootElementClasses( innerHTML ) {
	innerHTML = `<div data-custom-class-name="">${ innerHTML }</div>`;

	const parsed = parseWithAttributeSchema( innerHTML, {
		type: 'string',
		source: 'attribute',
		selector: '[data-custom-class-name] &gt; *',
		attribute: 'class',
	} );

	return parsed ? parsed.trim().split( /\s+/ ) : [];
}
github WordPress / gutenberg / editor / hooks / custom-class-name.js View on Github external
export function getHTMLRootElementClasses( innerHTML ) {
	innerHTML = `<div data-custom-class-name="">${ innerHTML }</div>`;

	const parsed = parseWithAttributeSchema( innerHTML, {
		type: 'string',
		source: 'attribute',
		selector: '[data-custom-class-name] &gt; *',
		attribute: 'class',
	} );

	return parsed ? parsed.trim().split( /\s+/ ) : [];
}
github WordPress / gutenberg / edit-post / hooks / components / media-upload / index.js View on Github external
processMediaCaption( mediaObject ) {
		return ! mediaObject.caption ?
			mediaObject :
			{ ...mediaObject, caption: parseWithAttributeSchema( mediaObject.caption, {
				source: 'children',
			} ) };
	}