From a23bf91e510fbbeafbde9cf95bfcb591c0b769d7 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 26 Oct 2017 09:07:17 -0400 Subject: [PATCH] Block List: Factor out BlockMultiControls component --- editor/modes/visual-editor/block.js | 25 ++++--------- editor/modes/visual-editor/multi-controls.js | 39 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 editor/modes/visual-editor/multi-controls.js diff --git a/editor/modes/visual-editor/block.js b/editor/modes/visual-editor/block.js index 901a70189870a..5765949396446 100644 --- a/editor/modes/visual-editor/block.js +++ b/editor/modes/visual-editor/block.js @@ -24,6 +24,7 @@ import BlockHtml from './block-html'; import BlockContextualToolbar from './block-contextual-toolbar'; import BlockMover from '../../block-mover'; import BlockSettingsMenu from '../../block-settings-menu'; +import BlockMultiControls from './multi-controls'; import { clearSelectedBlock, editPost, @@ -43,7 +44,6 @@ import { isMultiSelecting, getBlockIndex, getEditedPostAttribute, - getMultiSelectedBlockUids, getNextBlock, getPreviousBlock, isBlockHovered, @@ -299,7 +299,7 @@ class VisualEditorBlock extends Component { } render() { - const { block, multiSelectedBlockUids, order, mode } = this.props; + const { block, order, mode } = this.props; const { name: blockName, isValid } = block; const blockType = getBlockType( blockName ); // translators: %s: Type of block (i.e. Text, Image etc) @@ -323,13 +323,12 @@ class VisualEditorBlock extends Component { // Generate the wrapper class names handling the different states of the block. const { isHovered, isSelected, isMultiSelected, isFirstMultiSelected, focus } = this.props; const showUI = isSelected && ( ! this.props.isTyping || ( focus && focus.collapsed === false ) ); - const isProperlyHovered = isHovered && ! this.props.isSelecting; const { error } = this.state; const wrapperClassName = classnames( 'editor-visual-editor__block', { 'has-warning': ! isValid || !! error, 'is-selected': showUI, 'is-multi-selected': isMultiSelected, - 'is-hovered': isProperlyHovered, + 'is-hovered': isHovered, } ); const { onMouseLeave, onFocus, onReplace } = this.props; @@ -357,18 +356,10 @@ class VisualEditorBlock extends Component { { ...wrapperProps } > - { ( showUI || isProperlyHovered ) && } - { ( showUI || isProperlyHovered ) && } + { ( showUI || isHovered ) && } + { ( showUI || isHovered ) && } { showUI && isValid && } - { isFirstMultiSelected && ! this.props.isSelecting && - - } - { isFirstMultiSelected && ! this.props.isSelecting && - - } + { isFirstMultiSelected && }
, + , + ]; +} + +export default connect( ( state ) => { + return { + multiSelectedBlockUids: getMultiSelectedBlockUids( state ), + isSelecting: isMultiSelecting( state ), + }; +} )( VisualEditorBlockMultiControls );