Skip to content

Commit

Permalink
drop block movers into block edit to enable inline movers
Browse files Browse the repository at this point in the history
  • Loading branch information
draganescu committed Sep 26, 2019
1 parent 1a21b68 commit 7656896
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
33 changes: 18 additions & 15 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ function BlockListBlock( {
isSelected &&
! showEmptyBlockSideInserter &&
! isPartOfMultiSelection &&
! isTypingWithinBlock;
! isTypingWithinBlock &&
! horizontalMover;
const shouldShowBreadcrumb =
( isSelected && isNavigationMode ) ||
( ! isNavigationMode && ! isFocusMode && isHovered && ! isEmptyDefaultBlock );
Expand Down Expand Up @@ -451,6 +452,20 @@ function BlockListBlock( {
};
}
const blockElementId = `block-${ clientId }`;
const blockMover = (
<BlockMover
clientIds={ clientId }
blockElementId={ blockElementId }
isHidden={ ! isSelected }
isDraggable={
isDraggable !== false &&
( ! isPartOfMultiSelection && isMovable )
}
onDragStart={ onDragStart }
onDragEnd={ onDragEnd }
horizontalMover={ horizontalMover }
/>
);

// We wrap the BlockEdit component in a div that hides it when editing in
// HTML mode. This allows us to render all of the ancillary pieces
Expand All @@ -468,6 +483,7 @@ function BlockListBlock( {
clientId={ clientId }
isSelectionEnabled={ isSelectionEnabled }
toggleSelection={ toggleSelection }
blockMover={ horizontalMover ? blockMover : null }
/>
);
if ( mode !== 'visual' ) {
Expand Down Expand Up @@ -518,20 +534,7 @@ function BlockListBlock( {
/>
) }
<div className="editor-block-list__block-edit block-editor-block-list__block-edit">
{ shouldRenderMovers && (
<BlockMover
clientIds={ clientId }
blockElementId={ blockElementId }
isHidden={ ! isSelected }
isDraggable={
isDraggable !== false &&
( ! isPartOfMultiSelection && isMovable )
}
onDragStart={ onDragStart }
onDragEnd={ onDragEnd }
horizontalMover={ horizontalMover }
/>
) }
{ shouldRenderMovers && blockMover }
{ shouldShowBreadcrumb && (
<BlockBreadcrumb
clientId={ clientId }
Expand Down
12 changes: 12 additions & 0 deletions packages/block-editor/src/components/block-mover/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
.block-editor-block-mover {

&.is-horizontal {
display: grid;
grid-template-columns: 1fr 1fr;
width: auto;
min-height: auto;

.block-editor-block-mover__control-drag-handle {
display: none;
}

}

@include break-small() {
min-height: $empty-paragraph-height;
opacity: 0;
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/navigation-menu-item/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function NavigationMenuItemEdit( {
clientId,
isSelected,
setAttributes,
blockMover,
} ) {
const plainTextRef = useRef( null );
const onEditLableClicked = useCallback(
Expand All @@ -59,6 +60,7 @@ function NavigationMenuItemEdit( {
aria-label={ __( 'Navigation Label' ) }
maxRows={ 1 }
/>
{ blockMover }
<Dropdown
contentClassName="wp-block-navigation-menu-item__dropdown-content"
position="bottom left"
Expand Down

0 comments on commit 7656896

Please sign in to comment.