Skip to content

Commit

Permalink
[RNMobile] Native mobile release v1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tug authored and marecar3 committed Jul 26, 2019
1 parent 50880f6 commit a5dc5ae
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions packages/block-editor/src/components/block-list/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,15 @@ export class BlockList extends Component {
// create an empty block of the selected type
const newBlock = createBlock( itemValue );

this.finishInsertingOrReplacingBlock( newBlock );
this.finishBlockAppendingOrReplacing( newBlock );
}

finishInsertingOrReplacingBlock( newBlock ) {
finishBlockAppendingOrReplacing( newBlock ) {
// now determine whether we need to replace the currently selected block (if it's empty)
// or just add a new block as usual
if ( this.isReplaceable( this.props.selectedBlock ) ) {
// replace selected block
// do replace here
this.props.replaceBlock( this.props.selectedBlockClientId, newBlock );
} else if ( this.props.isPostTitleSelected && this.isReplaceable( this.props.firstBlock ) ) {
// replace first block in post: there is no selected block when the post title is selected,
// so replaceBlock does not select the new block and we need to manually select the new block
const { clientId: firstBlockId } = this.props.firstBlock;
this.props.replaceBlock( firstBlockId, newBlock );
this.props.selectBlock( newBlock.clientId );
} else {
this.props.insertBlock( newBlock, this.getNewBlockInsertionIndex() );
}
Expand Down Expand Up @@ -114,7 +110,7 @@ export class BlockList extends Component {
newMediaBlock.attributes.id = payload.mediaId;

// finally append or replace as appropriate
this.finishInsertingOrReplacingBlock( newMediaBlock );
this.finishBlockAppendingOrReplacing( newMediaBlock );
} );
}

Expand Down Expand Up @@ -264,7 +260,7 @@ export class BlockList extends Component {
const paragraphBlock = createBlock( 'core/paragraph' );
return (
<TouchableWithoutFeedback onPress={ () => {
this.finishInsertingOrReplacingBlock( paragraphBlock );
this.finishBlockAppendingOrReplacing( paragraphBlock );
} } >
<View style={ styles.blockListFooter } />
</TouchableWithoutFeedback>
Expand All @@ -281,7 +277,6 @@ export class BlockList extends Component {
export default compose( [
withSelect( ( select, { rootClientId } ) => {
const {
getBlock,
getBlockCount,
getBlockName,
getBlockIndex,
Expand All @@ -292,15 +287,13 @@ export default compose( [
} = select( 'core/block-editor' );

const selectedBlockClientId = getSelectedBlockClientId();
const blockClientIds = getBlockOrder( rootClientId );

return {
blockClientIds,
blockClientIds: getBlockOrder( rootClientId ),
blockCount: getBlockCount( rootClientId ),
getBlockName,
isBlockSelected,
selectedBlock: getSelectedBlock(),
firstBlock: getBlock( blockClientIds[ 0 ] ),
selectedBlockClientId,
selectedBlockOrder: getBlockIndex( selectedBlockClientId ),
};
Expand All @@ -310,14 +303,12 @@ export default compose( [
insertBlock,
replaceBlock,
clearSelectedBlock,
selectBlock,
} = dispatch( 'core/block-editor' );

return {
clearSelectedBlock,
insertBlock,
replaceBlock,
selectBlock,
};
} ),
] )( BlockList );
Expand Down

0 comments on commit a5dc5ae

Please sign in to comment.