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 Dec 11, 2019
1 parent f92fed7 commit d7c56fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 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
9 changes: 8 additions & 1 deletion packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class EditorProvider extends Component {
reusableBlocks,
__experimentalFetchReusableBlocks,
hasUploadPermissions,
canUserUseUnfilteredHTML
canUserUseUnfilteredHTML,
__experimentalShouldInsertAtTheTop
) {
return {
...pick( settings, [
Expand Down Expand Up @@ -118,6 +119,7 @@ class EditorProvider extends Component {
__experimentalFetchReusableBlocks,
__experimentalFetchLinkSuggestions: fetchLinkSuggestions,
__experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML,
__experimentalShouldInsertAtTheTop,
};
}

Expand Down Expand Up @@ -163,6 +165,7 @@ class EditorProvider extends Component {
reusableBlocks,
resetEditorBlocksWithoutUndoLevel,
hasUploadPermissions,
isPostTitleSelected,
__experimentalFetchReusableBlocks,
} = this.props;

Expand All @@ -176,6 +179,7 @@ class EditorProvider extends Component {
__experimentalFetchReusableBlocks,
hasUploadPermissions,
canUserUseUnfilteredHTML,
isPostTitleSelected,
);

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

Expand All @@ -221,6 +226,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 d7c56fe

Please sign in to comment.