From 76240915efdb721708d558238427e66117bc60c3 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Mon, 25 Feb 2019 14:43:48 +0100 Subject: [PATCH] Pass isTextModeEnabled as prop from parent. --- .../src/components/header/header-toolbar/index.js | 7 ++++--- .../editor/src/components/block-navigation/dropdown.js | 5 ++--- packages/editor/src/components/document-outline/index.js | 7 +++---- packages/editor/src/components/table-of-contents/index.js | 4 ++-- packages/editor/src/components/table-of-contents/panel.js | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/edit-post/src/components/header/header-toolbar/index.js b/packages/edit-post/src/components/header/header-toolbar/index.js index 87a24a85e2a8a3..7740b3b157a993 100644 --- a/packages/edit-post/src/components/header/header-toolbar/index.js +++ b/packages/edit-post/src/components/header/header-toolbar/index.js @@ -21,7 +21,7 @@ import { */ import FullscreenModeClose from '../fullscreen-mode-close'; -function HeaderToolbar( { hasFixedToolbar, isLargeViewport, showInserter } ) { +function HeaderToolbar( { hasFixedToolbar, isLargeViewport, showInserter, isTextModeEnabled } ) { const toolbarAriaLabel = hasFixedToolbar ? /* translators: accessibility text for the editor toolbar when Top Toolbar is on */ __( 'Document and block tools' ) : @@ -42,8 +42,8 @@ function HeaderToolbar( { hasFixedToolbar, isLargeViewport, showInserter } ) { - - + + { hasFixedToolbar && isLargeViewport && (
@@ -58,6 +58,7 @@ export default compose( [ hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ), // This setting (richEditingEnabled) should not live in the block editor's setting. showInserter: select( 'core/edit-post' ).getEditorMode() === 'visual' && select( 'core/block-editor' ).getEditorSettings().richEditingEnabled, + isTextModeEnabled: select( 'core/edit-post' ).getEditorMode() === 'text', } ) ), withViewportMatch( { isLargeViewport: 'medium' } ), ] )( HeaderToolbar ); diff --git a/packages/editor/src/components/block-navigation/dropdown.js b/packages/editor/src/components/block-navigation/dropdown.js index 62c9fcc67266eb..35db5d9b2d1f27 100644 --- a/packages/editor/src/components/block-navigation/dropdown.js +++ b/packages/editor/src/components/block-navigation/dropdown.js @@ -18,8 +18,8 @@ const MenuIcon = ( ); -function BlockNavigationDropdown( { hasBlocks, isTextModeEnabled } ) { - const isEnabled = hasBlocks && ! isTextModeEnabled; +function BlockNavigationDropdown( { hasBlocks, isDisabled } ) { + const isEnabled = hasBlocks && ! isDisabled; return ( { return { hasBlocks: !! select( 'core/block-editor' ).getBlockCount(), - isTextModeEnabled: select( 'core/edit-post' ).getEditorMode() === 'text', }; } )( BlockNavigationDropdown ); diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index 8694f77994c0ac..63349419e43b69 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -64,7 +64,7 @@ const computeOutlineHeadings = ( blocks = [], path = [] ) => { const isEmptyHeading = ( heading ) => ! heading.attributes.content || heading.attributes.content.length === 0; -export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupported, isTextModeEnabled } ) => { +export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupported, hasOutlineItemsDisabled } ) => { const headings = computeOutlineHeadings( blocks ); if ( headings.length < 1 ) { @@ -96,7 +96,7 @@ export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupporte level={ __( 'Title' ) } isValid onClick={ focusTitle } - isDisabled={ isTextModeEnabled } + isDisabled={ hasOutlineItemsDisabled } > { title } @@ -121,7 +121,7 @@ export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupporte isValid={ isValid } onClick={ () => onSelectHeading( item.clientId ) } path={ item.path } - isDisabled={ isTextModeEnabled } + isDisabled={ hasOutlineItemsDisabled } > { item.isEmpty ? emptyHeadingContent : @@ -150,7 +150,6 @@ export default compose( title: getEditedPostAttribute( 'title' ), blocks: getBlocks(), isTitleSupported: get( postType, [ 'supports', 'title' ], false ), - isTextModeEnabled: select( 'core/edit-post' ).getEditorMode() === 'text', }; } ), withDispatch( ( dispatch ) => { diff --git a/packages/editor/src/components/table-of-contents/index.js b/packages/editor/src/components/table-of-contents/index.js index af398e060085c3..767f51dc6c1afa 100644 --- a/packages/editor/src/components/table-of-contents/index.js +++ b/packages/editor/src/components/table-of-contents/index.js @@ -10,7 +10,7 @@ import { withSelect } from '@wordpress/data'; */ import TableOfContentsPanel from './panel'; -function TableOfContents( { hasBlocks } ) { +function TableOfContents( { hasBlocks, hasOutlineItemsDisabled } ) { return ( ) } - renderContent={ () => } + renderContent={ () => } /> ); } diff --git a/packages/editor/src/components/table-of-contents/panel.js b/packages/editor/src/components/table-of-contents/panel.js index 00489ccaf1e1d3..a1a2a4b4130557 100644 --- a/packages/editor/src/components/table-of-contents/panel.js +++ b/packages/editor/src/components/table-of-contents/panel.js @@ -11,7 +11,7 @@ import { withSelect } from '@wordpress/data'; import WordCount from '../word-count'; import DocumentOutline from '../document-outline'; -function TableOfContentsPanel( { headingCount, paragraphCount, numberOfBlocks } ) { +function TableOfContentsPanel( { headingCount, paragraphCount, numberOfBlocks, hasOutlineItemsDisabled } ) { return (
{ __( 'Document Outline' ) } - + ) }