-
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.
Move the block movers to the block toolbar
1 parent
cc378e8
commit e2a8e8e
Showing
17 changed files
with
169 additions
and
391 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
21 changes: 0 additions & 21 deletions
21
packages/block-editor/src/components/block-list/block-mobile-toolbar.js
This file was deleted.
Oops, something went wrong.
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
39 changes: 0 additions & 39 deletions
39
packages/block-editor/src/components/block-list/multi-controls.js
This file was deleted.
Oops, something went wrong.
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
93 changes: 0 additions & 93 deletions
93
packages/block-editor/src/components/block-mover/style.scss
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
28 changes: 0 additions & 28 deletions
28
packages/block-editor/src/components/block-switcher/multi-blocks-switcher.js
This file was deleted.
Oops, something went wrong.
58 changes: 28 additions & 30 deletions
58
packages/block-editor/src/components/block-toolbar/index.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 |
---|---|---|
@@ -1,56 +1,54 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { withSelect } from '@wordpress/data'; | ||
import { useSelect } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockMover from '../block-mover'; | ||
import BlockSwitcher from '../block-switcher'; | ||
import MultiBlocksSwitcher from '../block-switcher/multi-blocks-switcher'; | ||
import BlockControls from '../block-controls'; | ||
import BlockFormatControls from '../block-format-controls'; | ||
import BlockSettingsMenu from '../block-settings-menu'; | ||
|
||
function BlockToolbar( { blockClientIds, isValid, mode } ) { | ||
if ( blockClientIds.length === 0 ) { | ||
return null; | ||
} | ||
function BlockToolbar( { moverDirection } ) { | ||
const { blockIds, isValid, mode } = useSelect( ( select ) => { | ||
const { | ||
getBlockMode, | ||
getSelectedBlockClientIds, | ||
isBlockValid, | ||
} = select( 'core/block-editor' ); | ||
const blockClientIds = getSelectedBlockClientIds(); | ||
return { | ||
blockIds: blockClientIds, | ||
isValid: blockClientIds.length === 1 ? isBlockValid( blockClientIds[ 0 ] ) : null, | ||
mode: blockClientIds.length === 1 ? getBlockMode( blockClientIds[ 0 ] ) : null, | ||
}; | ||
} ); | ||
|
||
if ( blockClientIds.length > 1 ) { | ||
return ( | ||
<div className="editor-block-toolbar block-editor-block-toolbar"> | ||
<MultiBlocksSwitcher /> | ||
<BlockSettingsMenu clientIds={ blockClientIds } /> | ||
</div> | ||
); | ||
if ( blockIds.length === 0 ) { | ||
return null; | ||
} | ||
const shouldShowVisualToolbar = isValid && mode === 'visual'; | ||
const isMultiToolbar = blockIds.length > 1; | ||
|
||
return ( | ||
<div className="editor-block-toolbar block-editor-block-toolbar"> | ||
{ mode === 'visual' && isValid && ( | ||
<BlockMover | ||
clientIds={ blockIds } | ||
__experimentalOrientation={ moverDirection } | ||
/> | ||
{ ( shouldShowVisualToolbar || isMultiToolbar ) && <BlockSwitcher clientIds={ blockIds } /> } | ||
{ shouldShowVisualToolbar && ! isMultiToolbar && ( | ||
<> | ||
<BlockSwitcher clientIds={ blockClientIds } /> | ||
<BlockControls.Slot bubblesVirtually className="block-editor-block-toolbar__slot" /> | ||
<BlockFormatControls.Slot bubblesVirtually className="block-editor-block-toolbar__slot" /> | ||
</> | ||
) } | ||
<BlockSettingsMenu clientIds={ blockClientIds } /> | ||
<BlockSettingsMenu clientIds={ blockIds } /> | ||
</div> | ||
); | ||
} | ||
|
||
export default withSelect( ( select ) => { | ||
const { | ||
getBlockMode, | ||
getSelectedBlockClientIds, | ||
isBlockValid, | ||
} = select( 'core/block-editor' ); | ||
const blockClientIds = getSelectedBlockClientIds(); | ||
|
||
return { | ||
blockClientIds, | ||
isValid: blockClientIds.length === 1 ? isBlockValid( blockClientIds[ 0 ] ) : null, | ||
mode: blockClientIds.length === 1 ? getBlockMode( blockClientIds[ 0 ] ) : null, | ||
}; | ||
} )( BlockToolbar ); | ||
export default BlockToolbar; |
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