Skip to content

Commit

Permalink
Update: Removed editor store usage from native mobile block editor in…
Browse files Browse the repository at this point in the history
…serter
  • Loading branch information
jorgefilipecosta committed Jan 11, 2020
1 parent 54aaba6 commit a3ba38f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/block-editor/src/components/inserter/menu.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default compose(
getBlockName,
getBlockRootClientId,
getBlockSelectionEnd,
getSettings,
} = select( 'core/block-editor' );
const {
getChildBlockNames,
Expand All @@ -130,10 +131,13 @@ export default compose(
}
const destinationRootBlockName = getBlockName( destinationRootClientId );

const { __experimentalShouldInsertAtTheTop: shouldInsertAtTheTop } = getSettings();

return {
rootChildBlocks: getChildBlockNames( destinationRootBlockName ),
items: getInserterItems( destinationRootClientId ),
destinationRootClientId,
shouldInsertAtTheTop,
};
} ),
withDispatch( ( dispatch, ownProps, { select } ) => {
Expand All @@ -154,13 +158,10 @@ export default compose(
getBlockSelectionEnd,
getBlockOrder,
} = select( 'core/block-editor' );
const {
isPostTitleSelected,
} = select( 'core/editor' );
const { clientId, destinationRootClientId, isAppender } = ownProps;
const { clientId, destinationRootClientId, isAppender, shouldInsertAtTheTop } = ownProps;

// if post title is selected insert as first block
if ( isPostTitleSelected() ) {
if ( shouldInsertAtTheTop ) {
return 0;
}

Expand Down
7 changes: 7 additions & 0 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class EditorProvider extends Component {
hasUploadPermissions,
canUserUseUnfilteredHTML,
undo,
shouldInsertAtTheTop,
) {
return {
...pick( settings, [
Expand Down Expand Up @@ -120,6 +121,7 @@ class EditorProvider extends Component {
__experimentalFetchLinkSuggestions: fetchLinkSuggestions,
__experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML,
__experimentalUndo: undo,
__experimentalShouldInsertAtTheTop: shouldInsertAtTheTop,
};
}

Expand Down Expand Up @@ -165,6 +167,7 @@ class EditorProvider extends Component {
reusableBlocks,
resetEditorBlocksWithoutUndoLevel,
hasUploadPermissions,
isPostTitleSelected,
__experimentalFetchReusableBlocks,
undo,
} = this.props;
Expand All @@ -180,6 +183,7 @@ class EditorProvider extends Component {
hasUploadPermissions,
canUserUseUnfilteredHTML,
undo,
isPostTitleSelected,
);

return (
Expand Down Expand Up @@ -214,6 +218,7 @@ export default compose( [
getEditorSelectionStart,
getEditorSelectionEnd,
__experimentalGetReusableBlocks,
isPostTitleSelected,
} = select( 'core/editor' );
const { canUser } = select( 'core' );

Expand All @@ -225,6 +230,8 @@ export default compose( [
selectionEnd: getEditorSelectionEnd(),
reusableBlocks: __experimentalGetReusableBlocks(),
hasUploadPermissions: defaultTo( canUser( 'create', 'media' ), true ),
// This selector is only defined on mobile.
isPostTitleSelected: isPostTitleSelected && isPostTitleSelected(),
};
} ),
withDispatch( ( dispatch ) => {
Expand Down

0 comments on commit a3ba38f

Please sign in to comment.