From 3f591685c9193bd60ff4bab88a9b05cd3f997069 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 | 7 +++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/inserter/menu.native.js b/packages/block-editor/src/components/inserter/menu.native.js index 782017a527d88..b7b9711841da1 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 521fde4409e6d..d3a2930080eac 100644 --- a/packages/editor/src/components/provider/index.js +++ b/packages/editor/src/components/provider/index.js @@ -83,6 +83,7 @@ class EditorProvider extends Component { hasUploadPermissions, canUserUseUnfilteredHTML, undo, + shouldInsertAtTheTop, ) { return { ...pick( settings, [ @@ -122,6 +123,7 @@ class EditorProvider extends Component { __experimentalFetchLinkSuggestions: fetchLinkSuggestions, __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML, __experimentalUndo: undo, + __experimentalShouldInsertAtTheTop: shouldInsertAtTheTop, }; } @@ -167,6 +169,7 @@ class EditorProvider extends Component { reusableBlocks, resetEditorBlocksWithoutUndoLevel, hasUploadPermissions, + isPostTitleSelected, __experimentalFetchReusableBlocks, undo, } = this.props; @@ -182,6 +185,7 @@ class EditorProvider extends Component { hasUploadPermissions, canUserUseUnfilteredHTML, undo, + isPostTitleSelected, ); return ( @@ -216,6 +220,7 @@ export default compose( [ getEditorSelectionStart, getEditorSelectionEnd, __experimentalGetReusableBlocks, + isPostTitleSelected, } = select( 'core/editor' ); const { canUser } = select( 'core' ); @@ -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 ) => {