Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions src/extensions/advanced-controls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,52 +91,6 @@ const useAdvancedControls = ( props ) => {
const hasStackedControl = hasBlockSupport( name, 'stackedOnMobile' );
const withBlockSpacing = hasBlockSupport( name, 'coBlocksSpacing' );

const handleMargins = ( target ) => {
if ( ! target.querySelector ) {
return;
}

const innerAlignmentBlock = target.querySelector( '.wp-block[data-align]' );
const setInnerAlignmentBlock = ( margin, val ) => {
if ( !! innerAlignmentBlock ) {
innerAlignmentBlock.style[ margin ] = val;
}
};
switch ( target.outerHTML.includes( 'data-coblocks-bottom-spacing' ) ) {
case true:
target.style.marginBottom = 0;
setInnerAlignmentBlock( 'marginBottom', 0 );
break;
case false:
target.style.marginBottom = null;
setInnerAlignmentBlock( 'marginBottom', null );
break;
}
switch ( target.outerHTML.includes( 'data-coblocks-top-spacing' ) ) {
case true:
target.style.marginTop = 0;
setInnerAlignmentBlock( 'marginTop', 0 );
break;
case false:
target.style.marginTop = null;
setInnerAlignmentBlock( 'marginTop', null );

break;
}
};

useEffect( ( ) => {
// Check if alignment wrapper has been applied - Gutenberg 8.2.1
if ( !! document.getElementsByClassName( 'block-editor-block-list__layout is-root-container' ).length ) {
const targetElems = document.querySelectorAll( '.block-editor-block-list__layout' );
targetElems.forEach( ( elem ) => {
elem.childNodes.forEach( ( child ) => {
handleMargins( child );
} );
} );
}
}, [ noBottomMargin, noTopMargin ] );

const hasAdvancedControl = !! hasStackedControl || !! withBlockSpacing;

return isSelected && hasAdvancedControl ? (
Expand Down