From 0c1daa30d0301bc0a3f96dde3c37405d27447806 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Mon, 12 Oct 2020 10:16:09 +1300 Subject: [PATCH] fixes from review --- packages/block-library/src/image/edit.js | 37 ++++++++++-------------- packages/block-library/src/image/save.js | 4 +-- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 56fbf2e163192..b7d0526779499 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -80,7 +80,7 @@ export function ImageEdit( { insertBlocksAfter, noticeOperations, onReplace, - context, + context: { allowAlign = true, allowResize = true, isList = false }, } ) { const { url = '', @@ -91,7 +91,6 @@ export function ImageEdit( { width, height, sizeSlug, - isListItem, } = attributes; const altRef = useRef(); @@ -110,12 +109,6 @@ export function ImageEdit( { return getSettings().mediaUpload; } ); - const allowResize = - context.allowResize !== undefined ? context.allowResize : true; - - const allowAlign = - context.allowBlockAlign !== undefined ? context.allowBlockAlign : true; - function onUploadError( message ) { noticeOperations.removeAllNotices(); noticeOperations.createErrorNotice( message ); @@ -271,10 +264,10 @@ export function ImageEdit( { }, [ isTemp ] ); useEffect( () => { - if ( context?.isList ) { - setAttributes( { isListItem: context.isList } ); + if ( isList ) { + setAttributes( { isListItem: isList } ); } - }, [ context ] ); + }, [ isList ] ); const isExternal = isExternalImage( id, url ); const controls = ( @@ -339,7 +332,7 @@ export function ImageEdit( { /> ); - if ( isListItem ) { + if ( isList ) { return ( <> { controls } @@ -351,17 +344,17 @@ export function ImageEdit( { ); - } else { - return ( - <> - { controls } -
- { image } - { mediaPlaceholder } -
- - ); } + + return ( + <> + { controls } +
+ { image } + { mediaPlaceholder } +
+ + ); } export default withNotices( ImageEdit ); diff --git a/packages/block-library/src/image/save.js b/packages/block-library/src/image/save.js index ea57abbff3286..52acdd70dbe24 100644 --- a/packages/block-library/src/image/save.js +++ b/packages/block-library/src/image/save.js @@ -66,7 +66,7 @@ export default function save( { attributes } ) { ); - if ( true === isListItem ) { + if ( isListItem ) { return (
  • { figure }
    @@ -83,7 +83,7 @@ export default function save( { attributes } ) { } return ( -
    +
    { figure }
    );