-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try a toolbar for the block navigator
- Loading branch information
Showing
4 changed files
with
97 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/block-editor/src/components/block-navigation/toolbar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
import { Button, ToolbarGroup } from '@wordpress/components'; | ||
import { insertAfter, trash } from '@wordpress/icons'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockActions from '../block-actions'; | ||
import BlockMover from '../block-mover'; | ||
|
||
export default function BlockNavigationToolbar() { | ||
const blockClientIds = useSelect( ( select ) => | ||
select( 'core/block-editor' ).getSelectedBlockClientIds() | ||
); | ||
|
||
return ( | ||
<BlockActions clientIds={ blockClientIds }> | ||
{ ( { canDuplicate, isLocked, onDuplicate, onRemove } ) => ( | ||
<div className="block-editor-block-navigation-toolbar"> | ||
<BlockMover | ||
clientIds={ blockClientIds } | ||
__experimentalOrientation="vertical" | ||
hideDragHandle | ||
/> | ||
{ ! isLocked && ( | ||
<ToolbarGroup> | ||
{ canDuplicate && ( | ||
<Button | ||
onClick={ onDuplicate } | ||
label={ __( 'Duplicate block' ) } | ||
icon={ insertAfter } | ||
/> | ||
) } | ||
<Button | ||
onClick={ onRemove } | ||
label={ __( 'Remove block' ) } | ||
icon={ trash } | ||
/> | ||
</ToolbarGroup> | ||
) } | ||
</div> | ||
) } | ||
</BlockActions> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 22 additions & 8 deletions
30
packages/edit-navigation/src/components/menu-editor/navigation-structure-panel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters