Skip to content

Commit

Permalink
Lodash: Refactor away from BlockActions (#43846)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Sep 5, 2022
1 parent 05270d2 commit 95506f7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/block-editor/src/components/block-actions/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { castArray, first, last, every } from 'lodash';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -36,7 +31,7 @@ export default function BlockActions( {

const blocks = getBlocksByClientId( clientIds );
const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
const canDuplicate = every( blocks, ( block ) => {
const canDuplicate = blocks.every( ( block ) => {
return (
!! block &&
hasBlockSupport( block.name, 'multiple', true ) &&
Expand Down Expand Up @@ -80,10 +75,16 @@ export default function BlockActions( {
return removeBlocks( clientIds, updateSelection );
},
onInsertBefore() {
insertBeforeBlock( first( castArray( clientIds ) ) );
const clientId = Array.isArray( clientIds )
? clientIds[ 0 ]
: clientId;
insertBeforeBlock( clientId );
},
onInsertAfter() {
insertAfterBlock( last( castArray( clientIds ) ) );
const clientId = Array.isArray( clientIds )
? clientIds[ clientIds.length - 1 ]
: clientId;
insertAfterBlock( clientId );
},
onMoveTo() {
setNavigationMode( true );
Expand Down

0 comments on commit 95506f7

Please sign in to comment.