From 6f4e295977181644ba2afb72bcac7b9ba23811d2 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Fri, 12 Apr 2019 15:03:07 +0800 Subject: [PATCH] Remove HideWhenChildBlocks. This will be added on a separate branch --- .../src/components/inner-blocks/README.md | 10 ------ .../inner-blocks/hide-when-child-blocks.js | 32 ------------------- .../src/components/inner-blocks/index.js | 2 -- 3 files changed, 44 deletions(-) delete mode 100644 packages/block-editor/src/components/inner-blocks/hide-when-child-blocks.js diff --git a/packages/block-editor/src/components/inner-blocks/README.md b/packages/block-editor/src/components/inner-blocks/README.md index 8f2206c857e46e..4ad0c93c6e4aa2 100644 --- a/packages/block-editor/src/components/inner-blocks/README.md +++ b/packages/block-editor/src/components/inner-blocks/README.md @@ -123,7 +123,6 @@ Determines the placeholder behaviour when the Block is initially inserted. You m * For convenience two predefined appender components are exposed on `InnerBlocks` which can be consumed within the render function: - `` - display a `+` (plus) icon inside a box which fills the Block preview. No default Block is inserted. Clicking the appender reveals the Block picker UI. - `` - provides the default "auto-insert" functionality described above under `default`. - - `` - will only render `children` if the instance of `InnerBlocks` has no child blocks (typically only at point of first insertion). Once a child Block is added the `children` will not be rendered (see example usage below) * Consumers are also free to pass any valid render function which provides full flexibility to define a bespoke appender @@ -137,15 +136,6 @@ flexibility to define a bespoke appender ) } /> -// Will only display `ButtonBlockAppender` when there are no child blocks present - ( - - - - ) } -/> - // Fully custom ( diff --git a/packages/block-editor/src/components/inner-blocks/hide-when-child-blocks.js b/packages/block-editor/src/components/inner-blocks/hide-when-child-blocks.js deleted file mode 100644 index 837b7c0943efc0..00000000000000 --- a/packages/block-editor/src/components/inner-blocks/hide-when-child-blocks.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * WordPress dependencies - */ -import { compose, ifCondition } from '@wordpress/compose'; -import { withSelect } from '@wordpress/data'; - -/** - * Internal dependencies - */ -import withClientId from './with-client-id'; - -export const HideWhenChildBlocks = ( props ) => { - return props.children; -}; - -export default compose( [ - withClientId, - withSelect( ( select, { clientId } ) => { - const { - getBlock, - } = select( 'core/block-editor' ); - - const block = getBlock( clientId ); - - return { - hasChildBlocks: !! ( block && block.innerBlocks.length ), - }; - } ), - ifCondition( ( { hasChildBlocks } ) => { - return ! hasChildBlocks; - } ), -] )( HideWhenChildBlocks ); diff --git a/packages/block-editor/src/components/inner-blocks/index.js b/packages/block-editor/src/components/inner-blocks/index.js index ee224af8ecc285..3ee0947fd50816 100644 --- a/packages/block-editor/src/components/inner-blocks/index.js +++ b/packages/block-editor/src/components/inner-blocks/index.js @@ -19,7 +19,6 @@ import { compose } from '@wordpress/compose'; */ import ButtonBlockAppender from './button-block-appender'; import DefaultBlockAppender from './default-block-appender'; -import HideWhenChildBlocks from './hide-when-child-blocks'; /** * Internal dependencies @@ -173,7 +172,6 @@ InnerBlocks = compose( [ // Expose default appender placeholders as components. InnerBlocks.DefaultBlockAppender = DefaultBlockAppender; InnerBlocks.ButtonBlockAppender = ButtonBlockAppender; -InnerBlocks.HideWhenChildBlocks = HideWhenChildBlocks; InnerBlocks.Content = withBlockContentContext( ( { BlockContent } ) =>