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 Nov 27, 2019
1 parent 336f183 commit b7331fe
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 @@ -78,7 +78,8 @@ class EditorProvider extends Component {
settings,
reusableBlocks,
hasUploadPermissions,
canUserUseUnfilteredHTML
canUserUseUnfilteredHTML,
__experimentalShouldInsertAtTheTop
) {
return {
...pick( settings, [
Expand Down Expand Up @@ -113,6 +114,7 @@ class EditorProvider extends Component {
__experimentalReusableBlocks: reusableBlocks,
__experimentalFetchLinkSuggestions: fetchLinkSuggestions,
__experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML,
__experimentalShouldInsertAtTheTop,
};
}

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

if ( ! isReady ) {
Expand All @@ -169,6 +172,7 @@ class EditorProvider extends Component {
reusableBlocks,
hasUploadPermissions,
canUserUseUnfilteredHTML,
isPostTitleSelected,
);

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

Expand All @@ -214,6 +219,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 b7331fe

Please sign in to comment.