From bb0f0fd99bd3ca0d8afc4216b8eac34f3b5579bc Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Fri, 21 May 2021 19:53:55 +0200 Subject: [PATCH] Move ShouldInsertAtTheTop to native block editor settings --- .../src/components/provider/use-block-editor-settings.js | 9 +-------- .../provider/use-block-editor-settings.native.js | 7 +++++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/editor/src/components/provider/use-block-editor-settings.js b/packages/editor/src/components/provider/use-block-editor-settings.js index 592da3aaf026b7..158fa8d02f5363 100644 --- a/packages/editor/src/components/provider/use-block-editor-settings.js +++ b/packages/editor/src/components/provider/use-block-editor-settings.js @@ -33,11 +33,8 @@ function useBlockEditorSettings( settings, hasTemplate ) { reusableBlocks, hasUploadPermissions, canUseUnfilteredHTML, - isTitleSelected, } = useSelect( ( select ) => { - const { canUserUseUnfilteredHTML, isPostTitleSelected } = select( - editorStore - ); + const { canUserUseUnfilteredHTML } = select( editorStore ); const isWeb = Platform.OS === 'web'; const { canUser } = select( coreStore ); @@ -54,8 +51,6 @@ function useBlockEditorSettings( settings, hasTemplate ) { canUser( 'create', 'media' ), true ), - // This selector is only defined on mobile. - isTitleSelected: isPostTitleSelected && isPostTitleSelected(), }; }, [] ); @@ -111,7 +106,6 @@ function useBlockEditorSettings( settings, hasTemplate ) { fetchRemoteUrlData( url ), __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML, __experimentalUndo: undo, - __experimentalShouldInsertAtTheTop: isTitleSelected, outlineMode: hasTemplate, } ), [ @@ -120,7 +114,6 @@ function useBlockEditorSettings( settings, hasTemplate ) { reusableBlocks, canUseUnfilteredHTML, undo, - isTitleSelected, hasTemplate, ] ); diff --git a/packages/editor/src/components/provider/use-block-editor-settings.native.js b/packages/editor/src/components/provider/use-block-editor-settings.native.js index 57bfaf6fd3c08c..8baf2371442b2e 100644 --- a/packages/editor/src/components/provider/use-block-editor-settings.native.js +++ b/packages/editor/src/components/provider/use-block-editor-settings.native.js @@ -9,13 +9,14 @@ import { store as coreStore } from '@wordpress/core-data'; * Internal dependencies */ import useBlockEditorSettings from './use-block-editor-settings.js'; +import { store as editorStore } from '../../store'; function useNativeBlockEditorSettings( settings, hasTemplate ) { const capabilities = settings.capabilities ?? {}; const editorSettings = useBlockEditorSettings( settings, hasTemplate ); const supportReusableBlock = capabilities.reusableBlock === true; - const { reusableBlocks } = useSelect( + const { isTitleSelected, reusableBlocks } = useSelect( ( select ) => ( { reusableBlocks: supportReusableBlock ? select( coreStore ).getEntityRecords( @@ -26,6 +27,7 @@ function useNativeBlockEditorSettings( settings, hasTemplate ) { { per_page: 100 } ) : [], + isTitleSelected: select( editorStore ).isPostTitleSelected(), } ), [ supportReusableBlock ] ); @@ -34,8 +36,9 @@ function useNativeBlockEditorSettings( settings, hasTemplate ) { () => ( { ...editorSettings, __experimentalReusableBlocks: reusableBlocks, + __experimentalShouldInsertAtTheTop: isTitleSelected, } ), - [ reusableBlocks ] + [ editorSettings, reusableBlocks, isTitleSelected ] ); }