Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Generate a class name for the block's editable form
const generatedClassName = hasBlockSupport( blockType, 'className', true ) ?
getBlockDefaultClassName( name ) :
null;
const className = classnames( generatedClassName, attributes.className );
// `edit` and `save` are functions or components describing the markup
// with which a block is displayed. If `blockType` is valid, assign
// them preferentially as the render value for the block.
const Component = blockType.edit || blockType.save;
return ;
};
export default withFilters( 'editor.BlockEdit' )( Edit );
toggleSelection( selectionEnabled ) {
toggleSelection( selectionEnabled );
},
setNavigationMode,
};
} );
export default compose(
pure,
withViewportMatch( { isLargeViewport: 'medium' } ),
applyWithSelect,
applyWithDispatch,
// block is sometimes not mounted at the right time, causing it be undefined
// see issue for more info https://github.com/WordPress/gutenberg/issues/17013
ifCondition( ( { block } ) => !! block ),
withFilters( 'editor.BlockListBlock' )
)( BlockListBlock );
*/
import { withFilters } from '@wordpress/components';
/**
* This is a placeholder for the media upload component necessary to make it possible to provide
* an integration with the core blocks that handle media files. By default it renders nothing but
* it provides a way to have it overridden with the `editor.MediaUpload` filter.
*
* @return {WPElement} Media upload element.
*/
const MediaUpload = () => null;
/**
* @see https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/media-upload/README.md
*/
export default withFilters( 'editor.MediaUpload' )( MediaUpload );
const applyWithDispatch = withDispatch( ( dispatch ) => {
const { editPost } = dispatch( 'core/editor' );
return {
onUpdateImage( image ) {
editPost( { featured_media: image.id } );
},
onRemoveImage() {
editPost( { featured_media: 0 } );
},
};
} );
export default compose(
applyWithSelect,
applyWithDispatch,
withFilters( 'editor.PostFeaturedImage' ),
)( PostFeaturedImage );
const applyWithDispatch = withDispatch( ( dispatch ) => {
const { editPost } = dispatch( 'core/editor' );
return {
onUpdateImage( image ) {
editPost( { featured_media: image.id } );
},
onRemoveImage() {
editPost( { featured_media: 0 } );
},
};
} );
export default compose(
applyWithSelect,
applyWithDispatch,
withFilters( 'editor.PostFeaturedImage' ),
)( PostFeaturedImage );
replaceBlocks([ ownProps.clientId ], blocks);
},
onMetaChange (meta) {
editPost({ meta });
},
toggleSelection (selectionEnabled) {
toggleSelection(selectionEnabled);
},
};
});
export default compose(
withViewportMatch({ isLargeViewport: 'medium' }),
applyWithSelect,
applyWithDispatch,
withFilters('editor.BlockListBlock'),
withHoverAreas,
)(BlockListBlock);
export const Edit = ( props ) => {
const { name } = props;
const blockType = getBlockType( name );
if ( ! blockType ) {
return null;
}
const Component = blockType.edit;
return (
);
};
export default withFilters( 'editor.BlockEdit' )( Edit );
const taxonomy = getTaxonomy( slug );
return {
hasCreateAction: taxonomy ? get( getCurrentPost(), [ '_links', 'wp:action-create-' + taxonomy.rest_base ], false ) : false,
hasAssignAction: taxonomy ? get( getCurrentPost(), [ '_links', 'wp:action-assign-' + taxonomy.rest_base ], false ) : false,
terms: taxonomy ? select( 'core/editor' ).getEditedPostAttribute( taxonomy.rest_base ) : [],
taxonomy,
};
} ),
withDispatch( ( dispatch ) => {
return {
onUpdateTerms( terms, restBase ) {
dispatch( 'core/editor' ).editPost( { [ restBase ]: terms } );
},
};
} ),
withFilters( 'editor.PostTaxonomyType' ),
)( FlatTermSelector );
const taxonomy = getTaxonomy( slug );
return {
hasCreateAction: taxonomy ? get( getCurrentPost(), [ '_links', 'wp:action-create-' + taxonomy.rest_base ], false ) : false,
hasAssignAction: taxonomy ? get( getCurrentPost(), [ '_links', 'wp:action-assign-' + taxonomy.rest_base ], false ) : false,
terms: taxonomy ? select( 'core/editor' ).getEditedPostAttribute( taxonomy.rest_base ) : [],
taxonomy,
};
} ),
withDispatch( ( dispatch ) => {
return {
onUpdateTerms( terms, restBase ) {
dispatch( 'core/editor' ).editPost( { [ restBase ]: terms } );
},
};
} ),
withFilters( 'editor.PostTaxonomyType' ),
)( FlatTermSelector );
const taxonomy = getTaxonomy( slug );
return {
hasCreateAction: taxonomy ? get( getCurrentPost(), [ '_links', 'wp:action-create-' + taxonomy.rest_base ], false ) : false,
hasAssignAction: taxonomy ? get( getCurrentPost(), [ '_links', 'wp:action-assign-' + taxonomy.rest_base ], false ) : false,
terms: taxonomy ? select( 'core/editor' ).getEditedPostAttribute( taxonomy.rest_base ) : [],
taxonomy,
};
} ),
withDispatch( ( dispatch ) => ( {
onUpdateTerms( terms, restBase ) {
dispatch( 'core/editor' ).editPost( { [ restBase ]: terms } );
},
} ) ),
withSpokenMessages,
withInstanceId,
withFilters( 'editor.PostTaxonomyType' ),
] )( HierarchicalTermSelector );