Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dispatch('core/block-editor').updateBlockAttributes('foo', { foo: 'bar' });
// $ExpectType void
dispatch('core/block-editor').updateBlockListSettings('foo', { allowedBlocks: ['core/paragraph'] });
// $ExpectType void
dispatch('core/block-editor').updateSettings({
focusMode: true,
codeEditingEnabled: false,
maxUploadFileSize: 500,
richEditingEnabled: false,
});
// $ExpectType boolean
select('core/block-editor').canInsertBlockType('core/paragraph');
select('core/block-editor').canInsertBlockType('core/paragraph', 'foo');
// $ExpectType string | null
select('core/block-editor').getAdjacentBlockClientId();
select('core/block-editor').getAdjacentBlockClientId('foo');
select('core/block-editor').getAdjacentBlockClientId('foo', -1);
select('core/block-editor').getAdjacentBlockClientId('foo', 1);
function theImageUrl(props) {
let fallback = props.meta.cardImage || tcData.defaultImage;
const {getPostType} = select('core');
let postTypeCheck = getPostType(select('core/editor').getEditedPostAttribute('type'));// no use if no support for thumbnail
if (!postTypeCheck || !postTypeCheck.supports['thumbnail']) {
return fallback;
}
let featuredImageId = select('core/editor').getEditedPostAttribute('featured_media');
if (featuredImageId === 0) {
return fallback;
}
let media = select('core').getMedia(featuredImageId);
if (typeof(media) !== 'undefined') {
return props.meta.cardImage || media.source_url;
}
return fallback;
}
} ).then( ( body ) => {
// Prevent responses from old searches to be stored.
const current = select( STORE_NAME ).getSearch( id );
if ( current.trim() !== search.trim() ) {
return;
}
store.dispatch( {
type: 'SET_RESULTS',
id,
payload: {
results: body,
search,
},
} );
} );
// Only do this when there's a change in column number.
if ( typeof attributes.columns !== 'undefined' ) {
if ( attributes.columns !== blockProps.attributes.columns ) {
columns = attributes.columns
}
}
// Only do this when there's a change in the design.
if ( typeof attributes.design !== 'undefined' ) {
if ( blockProps.attributes.design === 'grid' && attributes.design !== 'grid' && blockProps.attributes.columns > 6 ) {
columns = 6
}
}
// Form the new innerBlock list.
const currentInnerBlocks = select( 'core/block-editor' ).getBlock( blockProps.clientId ).innerBlocks
const newInnerBlocks = range( columns || 2 ).map( i => {
return currentInnerBlocks[ i ] || createBlock( 'ugb/column', {}, [] )
} )
// Replace the current list of inner blocks.
dispatch( 'core/block-editor' ).replaceInnerBlocks( blockProps.clientId, newInnerBlocks, false )
return attributes
} )
if ( typeof settings.name !== 'string' ) {
window.console.error(
'Format names must be strings.'
);
return;
}
if ( ! /^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test( settings.name ) ) {
window.console.error(
'Format names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-format'
);
return;
}
if ( select( 'core/rich-text' ).getFormatType( settings.name ) ) {
window.console.error(
'Format "' + settings.name + '" is already registered.'
);
return;
}
if (
typeof settings.tagName !== 'string' ||
settings.tagName === ''
) {
window.console.error(
'Format tag names must be a string.'
);
return;
}
export function getDefaultBlockName() {
return select( 'core/blocks' ).getDefaultBlockName();
}
export const getPriceTypeObjects = () => select( 'eventespresso/lists' )
.getEntities( 'price_type' );
const mapDispatchToProps = ( dispatch ) => {
const postId = select( 'core/editor' ).getCurrentPostId();
return {
onRemove: () => dispatch( thunks.deleteRSVPHeaderImage( ownPrs.postId ) ),
/**
* Full payload from gutenberg media upload is not used,
* only id, alt, and medium src are used for this specific case.
*/
onSelect: ( image ) => dispatch(
thunks.updateRSVPHeaderImage( postId, image )
),
};
};
export default ( validateImageSize, invalidSizeMessage ) => {
const currentPost = select( 'core/editor' ).getCurrentPost();
const editedFeaturedMedia = select( 'core/editor' ).getEditedPostAttribute( 'featured_media' );
const featuredMedia = currentPost.featured_media || editedFeaturedMedia;
if ( ! featuredMedia ) {
return __( 'Selecting a featured image is required.', 'amp' );
}
const media = select( 'core' ).getMedia( featuredMedia );
if ( ! media || ! media.media_details || ! validateImageSize( media.media_details ) ) {
return invalidSizeMessage;
}
};
export function getItemStatus( state, itemId ) {
const item = select( 'course-learner/user' ).getItemById( itemId );
return item ? get( item, 'userSettings.status' ) : '';
}