-
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.
Allow dragging blocks from the inserter the canvas (#27669)
- Loading branch information
1 parent
38b829f
commit c183c32
Showing
14 changed files
with
253 additions
and
135 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
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
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
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
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
34 changes: 34 additions & 0 deletions
34
packages/block-editor/src/components/inserter-list-item/draggable.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,34 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Draggable } from '@wordpress/components'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockDraggableChip from '../block-draggable/draggable-chip'; | ||
|
||
const InserterListItemDraggable = ( { isEnabled, blocks, icon, children } ) => { | ||
const transferData = { | ||
type: 'inserter', | ||
blocks, | ||
}; | ||
|
||
return ( | ||
<Draggable | ||
transferData={ transferData } | ||
__experimentalDragComponent={ | ||
<BlockDraggableChip count={ blocks.length } icon={ icon } /> | ||
} | ||
> | ||
{ ( { onDraggableStart, onDraggableEnd } ) => { | ||
return children( { | ||
draggable: isEnabled, | ||
onDragStart: isEnabled ? onDraggableStart : undefined, | ||
onDragEnd: isEnabled ? onDraggableEnd : undefined, | ||
} ); | ||
} } | ||
</Draggable> | ||
); | ||
}; | ||
|
||
export default InserterListItemDraggable; |
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
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
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
Oops, something went wrong.