From e18e0a0e8b8470fc77e61e673410a50f14a6238a Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Thu, 23 Jan 2020 18:30:21 +0000 Subject: [PATCH] =?UTF-8?q?Update:=20Removed=20editor=20store=20usage=20fr?= =?UTF-8?q?om=20native=20mobile=20block=20ed=E2=80=A6=20(#18794)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 ) => {