Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// $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, {
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;
},
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] > *',
attribute: 'class',
} );
return parsed ? parsed.trim().split( /\s+/ ) : [];
}
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] > *',
attribute: 'class',
} );
return parsed ? parsed.trim().split( /\s+/ ) : [];
}
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] > *',
attribute: 'class',
} );
return parsed ? parsed.trim().split( /\s+/ ) : [];
}
processMediaCaption( mediaObject ) {
return ! mediaObject.caption ?
mediaObject :
{ ...mediaObject, caption: parseWithAttributeSchema( mediaObject.caption, {
source: 'children',
} ) };
}