-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove block switcher from header, add to multi block controls #7891
Changes from all commits
bd61dfb
62f8450
325cdae
829912a
bfa443c
9dd9c7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,29 +8,40 @@ import { withSelect } from '@wordpress/data'; | |
*/ | ||
import './style.scss'; | ||
import BlockSwitcher from '../block-switcher'; | ||
import MultiBlocksSwitcher from '../block-switcher/multi-blocks-switcher'; | ||
import BlockControls from '../block-controls'; | ||
import BlockFormatControls from '../block-format-controls'; | ||
|
||
function BlockToolbar( { block, mode } ) { | ||
if ( ! block || ! block.isValid || mode !== 'visual' ) { | ||
function BlockToolbar( { blockUIDs, isValid, mode } ) { | ||
if ( blockUIDs.length > 1 ) { | ||
return ( | ||
<div className="editor-block-toolbar"> | ||
<MultiBlocksSwitcher /> | ||
</div> | ||
); | ||
} | ||
|
||
if ( ! isValid || 'visual' !== mode ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="editor-block-toolbar"> | ||
<BlockSwitcher uids={ [ block.uid ] } /> | ||
<BlockSwitcher uids={ blockUIDs } /> | ||
<BlockControls.Slot /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it makes sense to keep the slots in case we want to show multi-selection controls or something like that in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we do, and I'm working on that next week in another PR :) So I'll be rebasing to use these changes in that PR |
||
<BlockFormatControls.Slot /> | ||
</div> | ||
); | ||
} | ||
|
||
export default withSelect( ( select ) => { | ||
const { getSelectedBlock, getBlockMode } = select( 'core/editor' ); | ||
const { getSelectedBlock, getBlockMode, getMultiSelectedBlockUids } = select( 'core/editor' ); | ||
const block = getSelectedBlock(); | ||
const blockUIDs = block ? [ block.uid ] : getMultiSelectedBlockUids(); | ||
|
||
return { | ||
block, | ||
blockUIDs, | ||
isValid: block ? block.isValid : null, | ||
mode: block ? getBlockMode( block.uid ) : null, | ||
}; | ||
} )( BlockToolbar ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this
MultiBlocksSwitcher
is already handling showing the switcher only for multi selection.We should:
block-toolbar
block-toolbar
directly