Skip to content

Commit

Permalink
Update: Removed editor store usage from native mobile block ed… (#18794)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta authored Jan 23, 2020
1 parent dcb08f3 commit e18e0a0
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 @@ -83,6 +83,7 @@ class EditorProvider extends Component {
hasUploadPermissions,
canUserUseUnfilteredHTML,
undo,
shouldInsertAtTheTop,
) {
return {
...pick( settings, [
Expand Down Expand Up @@ -122,6 +123,7 @@ class EditorProvider extends Component {
__experimentalFetchLinkSuggestions: fetchLinkSuggestions,
__experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML,
__experimentalUndo: undo,
__experimentalShouldInsertAtTheTop: shouldInsertAtTheTop,
};
}

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

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

Expand All @@ -227,6 +232,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 e18e0a0

Please sign in to comment.