@@ -33,31 +33,12 @@ export class BlockList extends Component {
33
33
this . renderDefaultBlockAppender = this . renderDefaultBlockAppender . bind ( this ) ;
34
34
this . onCaretVerticalPositionChange = this . onCaretVerticalPositionChange . bind ( this ) ;
35
35
this . scrollViewInnerRef = this . scrollViewInnerRef . bind ( this ) ;
36
- this . getNewBlockInsertionIndex = this . getNewBlockInsertionIndex . bind ( this ) ;
36
+ this . addBlockToEndOfPost = this . addBlockToEndOfPost . bind ( this ) ;
37
37
this . shouldFlatListPreventAutomaticScroll = this . shouldFlatListPreventAutomaticScroll . bind ( this ) ;
38
38
}
39
39
40
- finishBlockAppendingOrReplacing ( newBlock ) {
41
- // now determine whether we need to replace the currently selected block (if it's empty)
42
- // or just add a new block as usual
43
- if ( this . isReplaceable ( this . props . selectedBlock ) ) {
44
- // do replace here
45
- this . props . replaceBlock ( this . props . selectedBlockClientId , newBlock ) ;
46
- } else {
47
- this . props . insertBlock ( newBlock , this . getNewBlockInsertionIndex ( ) ) ;
48
- }
49
- }
50
-
51
- getNewBlockInsertionIndex ( ) {
52
- if ( this . props . isPostTitleSelected ) {
53
- // if post title selected, insert at top of post
54
- return 0 ;
55
- } else if ( this . props . selectedBlockIndex === - 1 ) {
56
- // if no block selected, insert at end of post
57
- return this . props . blockCount ;
58
- }
59
- // insert after selected block
60
- return this . props . selectedBlockIndex + 1 ;
40
+ addBlockToEndOfPost ( newBlock ) {
41
+ this . props . insertBlock ( newBlock , this . props . blockCount ) ;
61
42
}
62
43
63
44
blockHolderBorderStyle ( ) {
@@ -162,7 +143,7 @@ export class BlockList extends Component {
162
143
const paragraphBlock = createBlock ( 'core/paragraph' ) ;
163
144
return (
164
145
< TouchableWithoutFeedback onPress = { ( ) => {
165
- this . finishBlockAppendingOrReplacing ( paragraphBlock ) ;
146
+ this . addBlockToEndOfPost ( paragraphBlock ) ;
166
147
} } >
167
148
< View style = { styles . blockListFooter } />
168
149
</ TouchableWithoutFeedback >
@@ -174,10 +155,8 @@ export default compose( [
174
155
withSelect ( ( select , { rootClientId } ) => {
175
156
const {
176
157
getBlockCount,
177
- getBlockName,
178
158
getBlockIndex,
179
159
getBlockOrder,
180
- getSelectedBlock,
181
160
getSelectedBlockClientId,
182
161
getBlockInsertionPoint,
183
162
isBlockInsertionPointVisible,
@@ -210,13 +189,10 @@ export default compose( [
210
189
return {
211
190
blockClientIds,
212
191
blockCount : getBlockCount ( rootClientId ) ,
213
- getBlockName,
214
192
isBlockInsertionPointVisible : isBlockInsertionPointVisible ( ) ,
215
193
shouldShowBlockAtIndex,
216
194
shouldShowInsertionPoint,
217
- selectedBlock : getSelectedBlock ( ) ,
218
195
selectedBlockClientId,
219
- selectedBlockIndex,
220
196
} ;
221
197
} ) ,
222
198
withDispatch ( ( dispatch ) => {
0 commit comments