From 2b7521a23ef0fa0bf1bfe5977c13e7bd300abc15 Mon Sep 17 00:00:00 2001 From: Ella van Durpe Date: Thu, 11 Jun 2020 15:30:38 +0300 Subject: [PATCH 1/2] Block: move align wrapper out of Block element --- .../src/components/block-list/block-wrapper.js | 17 +---------------- .../src/components/block-list/block.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block-wrapper.js b/packages/block-editor/src/components/block-list/block-wrapper.js index 82e4b1fb8ec13b..78dbf69a3d0892 100644 --- a/packages/block-editor/src/components/block-list/block-wrapper.js +++ b/packages/block-editor/src/components/block-list/block-wrapper.js @@ -65,7 +65,6 @@ const BlockComponent = forwardRef( 'core/block-editor' ); const fallbackRef = useRef(); - const isAligned = wrapperProps && !! wrapperProps[ 'data-align' ]; wrapper = wrapper || fallbackRef; // Provide the selected node, or the first and last nodes of a multi- @@ -203,8 +202,7 @@ const BlockComponent = forwardRef( className={ classnames( className, props.className, - wrapperProps && wrapperProps.className, - ! isAligned && 'wp-block' + wrapperProps && wrapperProps.className ) } data-block={ clientId } data-type={ name } @@ -223,19 +221,6 @@ const BlockComponent = forwardRef( ); - // For aligned blocks, provide a wrapper element so the block can be - // positioned relative to the block column. - if ( isAligned ) { - const alignmentWrapperProps = { - 'data-align': wrapperProps[ 'data-align' ], - }; - return ( -
- { blockWrapper } -
- ); - } - return blockWrapper; } ); diff --git a/packages/block-editor/src/components/block-list/block.js b/packages/block-editor/src/components/block-list/block.js index f91b5e5223a98d..d7d7c951d31d38 100644 --- a/packages/block-editor/src/components/block-list/block.js +++ b/packages/block-editor/src/components/block-list/block.js @@ -107,6 +107,7 @@ function BlockListBlock( { ? getBlockDefaultClassName( name ) : null; const customClassName = lightBlockWrapper ? attributes.className : null; + const isAligned = wrapperProps && !! wrapperProps[ 'data-align' ]; // The wp-block className is important for editor styles. // Generate the wrapper class names handling the different states of the @@ -116,6 +117,7 @@ function BlockListBlock( { customClassName, 'block-editor-block-list__block', { + 'wp-block': ! isAligned, 'has-warning': ! isValid || !! hasError || isUnregisteredBlock, 'is-selected': isSelected, 'is-highlighted': isHighlighted, @@ -152,6 +154,19 @@ function BlockListBlock( { /> ); + // For aligned blocks, provide a wrapper element so the block can be + // positioned relative to the block column. + if ( isAligned ) { + const alignmentWrapperProps = { + 'data-align': wrapperProps[ 'data-align' ], + }; + blockEdit = ( +
+ { blockEdit } +
+ ); + } + if ( mode !== 'visual' ) { blockEdit =
{ blockEdit }
; } From 3a354a4526716e15fda41a21c7d01692c46a4a3f Mon Sep 17 00:00:00 2001 From: Ella van Durpe Date: Thu, 11 Jun 2020 15:36:50 +0300 Subject: [PATCH 2/2] Code formatting --- .../block-editor/src/components/block-list/block-wrapper.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block-wrapper.js b/packages/block-editor/src/components/block-list/block-wrapper.js index 78dbf69a3d0892..201276d151514b 100644 --- a/packages/block-editor/src/components/block-list/block-wrapper.js +++ b/packages/block-editor/src/components/block-list/block-wrapper.js @@ -190,7 +190,7 @@ const BlockComponent = forwardRef( mode === 'html' && ! __unstableIsHtml ? '-visual' : ''; const blockElementId = `block-${ clientId }${ htmlSuffix }`; - const blockWrapper = ( + return ( ); - - return blockWrapper; } );