Skip to content

Commit

Permalink
make button toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Oct 18, 2022
1 parent e10a645 commit 79caffe
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,23 @@ export default function Image( {
onChange={ updateAlignment }
/>
) }
{ ! isContentLocked && ! caption && (
{ ! isContentLocked && (
<ToolbarButton
onClick={ () => {
setShowCaption( ! showCaption );
if (
showCaption &&
! RichText.isEmpty( caption )
) {
setAttributes( { caption: undefined } );
}
} }
icon={ captionIcon }
disabled={ showCaption }
label={ __( 'Add caption' ) }
label={
showCaption
? __( 'Remove caption' )
: __( 'Add caption' )
}
/>
) }
{ ! multiImageSelection && ! isEditingImage && (
Expand Down

0 comments on commit 79caffe

Please sign in to comment.