Inserter - added direct insertion to block manager (take2)#110
Conversation
…ts BlockActionType
|
|
||
| // TODO: block type picker here instead of hardcoding a core/code block | ||
| const newBlock = createBlock( 'core/paragraph', { content: 'new test text for a core/paragraph block' } ); | ||
| const newBlockWithFocusedState = { ...newBlock, focused: false }; |
There was a problem hiding this comment.
I know it's not part of the PR's diff but, wdyt about doing a small optimization here by just appending to the object a new field instead of creating a full new object?
We can just do:
newBlock.focused = false;
and use the newBlock instead of construct the newBlockWithFocusedState.
| it( 'should create an action to create a block', () => { | ||
| const newBlock = createBlock( 'core/code', { content: 'new test text for a core/code block' } ); | ||
| const action = actions.createBlockAction( '1', newBlock ); | ||
| const action = actions.createBlockAction( '1', newBlock, '0' ); |
There was a problem hiding this comment.
Let's also test the clientIdAbove while at it, wdyt?
src/store/reducers/index.js
Outdated
| // TODO we need to set focused: true and search for the currently focused block and | ||
| // set that one to `focused: false`. | ||
| blocks.push(action.block); | ||
| insertBlock(blocks, action.block, action.clientIdAbove); |
There was a problem hiding this comment.
Hmm, should this insertBlock replace the blocks.push in the previous line?
There was a problem hiding this comment.
ooops thank Lord you catched that, addressed c1b51b9
src/store/reducers/index.js
Outdated
| // TODO we need to set focused: true and search for the currently focused block and | ||
| // set that one to `focused: false`. | ||
| const insertionIndex = findBlockIndex( blocks, clientIdAbove ); | ||
| if (insertionIndex === blocks.length - 1) { |
|
Nice one @mzorz ! I left a few comments, have a look and let me know if something is not clear! Thanks! |
|
Ready for another round @hypest - thank you! 🙇 |
|
flow has given its OK now with the new |
…oid-to-v1.3.14 Bump Aztec Android to v1.3.14
Closing #96 in favor of this one, as the base branch of #95 is not needed anymore, and avoid messing with commit history
Adds direct insertion at a specific index in the list state. For the sake of the exercise in the GB mobile application for now we're inserting right below the tapped block.
Before, it would only append new blocks to the list.
Android
iOS