From d7c56fe560a0eab581f310169dfa044b19568234 Mon Sep 17 00:00:00 2001 From: Jorge Date: Wed, 27 Nov 2019 20:30:26 +0000 Subject: [PATCH] Update: Removed editor store usage from native mobile block editor inserter --- .../src/components/inserter/menu.native.js | 11 ++++++----- packages/editor/src/components/provider/index.js | 9 ++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/inserter/menu.native.js b/packages/block-editor/src/components/inserter/menu.native.js index 591932dde8ab62..9b0ac2dbc4425b 100644 --- a/packages/block-editor/src/components/inserter/menu.native.js +++ b/packages/block-editor/src/components/inserter/menu.native.js @@ -116,6 +116,7 @@ export default compose( getBlockName, getBlockRootClientId, getBlockSelectionEnd, + getSettings, } = select( 'core/block-editor' ); const { getChildBlockNames, @@ -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 } ) => { @@ -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; } diff --git a/packages/editor/src/components/provider/index.js b/packages/editor/src/components/provider/index.js index 1d3714e5c09885..ef976d53f82d0a 100644 --- a/packages/editor/src/components/provider/index.js +++ b/packages/editor/src/components/provider/index.js @@ -79,7 +79,8 @@ class EditorProvider extends Component { reusableBlocks, __experimentalFetchReusableBlocks, hasUploadPermissions, - canUserUseUnfilteredHTML + canUserUseUnfilteredHTML, + __experimentalShouldInsertAtTheTop ) { return { ...pick( settings, [ @@ -118,6 +119,7 @@ class EditorProvider extends Component { __experimentalFetchReusableBlocks, __experimentalFetchLinkSuggestions: fetchLinkSuggestions, __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML, + __experimentalShouldInsertAtTheTop, }; } @@ -163,6 +165,7 @@ class EditorProvider extends Component { reusableBlocks, resetEditorBlocksWithoutUndoLevel, hasUploadPermissions, + isPostTitleSelected, __experimentalFetchReusableBlocks, } = this.props; @@ -176,6 +179,7 @@ class EditorProvider extends Component { __experimentalFetchReusableBlocks, hasUploadPermissions, canUserUseUnfilteredHTML, + isPostTitleSelected, ); return ( @@ -210,6 +214,7 @@ export default compose( [ getEditorSelectionStart, getEditorSelectionEnd, __experimentalGetReusableBlocks, + isPostTitleSelected, } = select( 'core/editor' ); const { canUser } = select( 'core' ); @@ -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 ) => {