-
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.
Adding an inserter next to the last block
- Loading branch information
1 parent
119c136
commit 47f5b07
Showing
5 changed files
with
99 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { connect } from 'react-redux'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { | ||
getBlockUids, | ||
getBlockInsertionPoint, | ||
isBlockInsertionPointVisible, | ||
} from '../../store/selectors'; | ||
import { | ||
clearSelectedBlock, | ||
} from '../../store/actions'; | ||
|
||
/** | ||
* Component showing the block's insertion point. | ||
* | ||
* @param {Object} props React props passed to the component. | ||
* @returns {Object|false} Rendered insertion point. | ||
*/ | ||
function BlockListInsertionPoint( { showInsertionPoint } ) { | ||
return showInsertionPoint && ( | ||
<div className="editor-block-list__insertion-point" /> | ||
); | ||
} | ||
|
||
export default connect( | ||
( state, { uid } ) => { | ||
const blockIndex = uid ? getBlockUids( state ).indexOf( uid ) : -1; | ||
const insertIndex = blockIndex > -1 ? blockIndex + 1 : 0; | ||
|
||
return { | ||
showInsertionPoint: ( | ||
isBlockInsertionPointVisible( state ) && | ||
getBlockInsertionPoint( state ) === insertIndex | ||
), | ||
}; | ||
}, | ||
{ | ||
clearSelectedBlock, | ||
} | ||
)( BlockListInsertionPoint ); |
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