Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { downloadButtonText, href } = attributes;
// Upload a file drag-and-dropped into the editor
if ( isBlobURL( href ) ) {
const file = getBlobByURL( href );
mediaUpload( {
filesList: [ file ],
onFileChange: ( [ media ] ) => this.onSelectFile( media ),
onError: ( message ) => {
this.setState( { hasError: true } );
noticeOperations.createErrorNotice( message );
},
} );
revokeBlobURL( href );
}
if ( downloadButtonText === undefined ) {
setAttributes( {
downloadButtonText: _x( 'Download', 'button label' ),
} );
}
}
const { downloadButtonText, href } = attributes;
// Upload a file drag-and-dropped into the editor
if ( isBlobURL( href ) ) {
const file = getBlobByURL( href );
mediaUpload( {
filesList: [ file ],
onFileChange: ( [ media ] ) => this.onSelectFile( media ),
onError: ( message ) => {
this.setState( { hasError: true } );
noticeOperations.createErrorNotice( message );
},
} );
revokeBlobURL( href );
}
if ( downloadButtonText === undefined ) {
setAttributes( {
downloadButtonText: _x( 'Download', 'button label' ),
} );
}
}
componentDidUpdate( prevProps ) {
const { id: prevID, url: prevURL = '' } = prevProps.attributes;
const { id, url = '' } = this.props.attributes;
if ( isTemporaryImage( prevID, prevURL ) && ! isTemporaryImage( id, url ) ) {
revokeBlobURL( url );
}
if ( ! this.props.isSelected && prevProps.isSelected && this.state.captionFocused ) {
this.setState( {
captionFocused: false,
} );
}
}
componentDidUpdate (prevProps) {
const { id: prevID, url: prevURL = '' } = prevProps.attributes;
const { id, url = '' } = this.props.attributes;
if (isTemporaryImage(prevID, prevURL) && ! isTemporaryImage(id, url)) {
revokeBlobURL(url);
}
if (! this.props.isSelected && prevProps.isSelected && this.state.captionFocused) {
this.setState({
captionFocused: false,
});
}
}
const setAndUpdateFiles = ( idx, value ) => {
revokeBlobURL( get( filesSet, [ idx, 'url' ] ) );
filesSet[ idx ] = value;
onFileChange( compact( filesSet ) );
};
componentDidUpdate( prevProps ) {
const { id: prevID, url: prevURL = '' } = prevProps.attributes;
const { id, url = '' } = this.props.attributes;
if ( isTemporaryImage( prevID, prevURL ) && ! isTemporaryImage( id, url ) ) {
revokeBlobURL( url );
}
if ( ! this.props.isSelected && prevProps.isSelected && this.state.captionFocused ) {
this.setState( {
captionFocused: false,
} );
}
}
forEach( images, ( { url } ) => revokeBlobURL( url ) );
mediaUpload( {
forEach( images, ( { url } ) => revokeBlobURL( url ) );
mediaUpload( {