From 2674522f31a0940bc64d646880b96d001944028c Mon Sep 17 00:00:00 2001 From: Jakub Binda Date: Mon, 18 Nov 2019 10:03:46 +0100 Subject: [PATCH 1/7] fix show appender in group block --- .../src/components/block-list/index.native.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/block-editor/src/components/block-list/index.native.js b/packages/block-editor/src/components/block-list/index.native.js index c291cec2215d39..deb7cf5e7b0e4c 100644 --- a/packages/block-editor/src/components/block-list/index.native.js +++ b/packages/block-editor/src/components/block-list/index.native.js @@ -63,13 +63,12 @@ export class BlockList extends Component { const willShowInsertionPoint = shouldShowInsertionPointBefore(); // call without the client_id argument since this is the appender return ( - { willShowInsertionPoint ? - this.renderAddBlockSeparator() : // show the new-block indicator when we're inserting a block or - - } + { /* show the new-block indicator when we're inserting a block */ } + { willShowInsertionPoint && this.renderAddBlockSeparator() } + ); } From 722134da5e5acc936aa3552477c5b0be6e0a6179 Mon Sep 17 00:00:00 2001 From: Jakub Binda Date: Fri, 29 Nov 2019 12:10:27 +0100 Subject: [PATCH 2/7] add isOpen check to conditionally show/hide appender button under group block --- .../src/components/button-block-appender/index.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/button-block-appender/index.native.js b/packages/block-editor/src/components/button-block-appender/index.native.js index b01d3b65109856..3ec783488d257c 100644 --- a/packages/block-editor/src/components/button-block-appender/index.native.js +++ b/packages/block-editor/src/components/button-block-appender/index.native.js @@ -20,7 +20,7 @@ function ButtonBlockAppender( { rootClientId } ) { ( - + ) ) } isAppender + showSeparator={ showSeparator } /> ); diff --git a/packages/block-editor/src/components/inserter/index.native.js b/packages/block-editor/src/components/inserter/index.native.js index 4c06402af38214..aa4adeaa2a3746 100644 --- a/packages/block-editor/src/components/inserter/index.native.js +++ b/packages/block-editor/src/components/inserter/index.native.js @@ -13,6 +13,7 @@ import { getUnregisteredTypeHandlerName } from '@wordpress/blocks'; */ import styles from './style.scss'; import InserterMenu from './menu'; +import AddBlockSeparator from '../add-block-separator'; const defaultRenderToggle = ( { onToggle, disabled, style } ) => ( ; + } const style = getStylesFromColorScheme( styles.addBlockButton, styles.addBlockButtonDark ); return renderToggle( { onToggle, isOpen, disabled, style } ); } From 40a9118cdaecb7ce082c0799363a7fd06807af9f Mon Sep 17 00:00:00 2001 From: Dratwas Date: Tue, 10 Dec 2019 18:43:45 +0100 Subject: [PATCH 4/7] pass showSeparator --- .../src/components/inner-blocks/button-block-appender.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/inner-blocks/button-block-appender.js b/packages/block-editor/src/components/inner-blocks/button-block-appender.js index af4f355e861efa..6e26bb0856b5ac 100644 --- a/packages/block-editor/src/components/inner-blocks/button-block-appender.js +++ b/packages/block-editor/src/components/inner-blocks/button-block-appender.js @@ -4,9 +4,9 @@ import BaseButtonBlockAppender from '../button-block-appender'; import withClientId from './with-client-id'; -export const ButtonBlockAppender = ( { clientId } ) => { +export const ButtonBlockAppender = ( { clientId, showSeparator } ) => { return ( - + ); }; From b377ff6bb6d25eeb2847841d9efa1a1bad58601d Mon Sep 17 00:00:00 2001 From: Dratwas Date: Tue, 10 Dec 2019 18:48:08 +0100 Subject: [PATCH 5/7] code-styling fix --- .../src/components/button-block-appender/index.native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/button-block-appender/index.native.js b/packages/block-editor/src/components/button-block-appender/index.native.js index bcd6389ef8f450..12f285f7185fd0 100644 --- a/packages/block-editor/src/components/button-block-appender/index.native.js +++ b/packages/block-editor/src/components/button-block-appender/index.native.js @@ -20,7 +20,7 @@ function ButtonBlockAppender( { rootClientId, showSeparator } ) { ( - ( ) + ) } isAppender showSeparator={ showSeparator } From d6dc4a79f3cb3b96eed0963397d46fe75b4d824e Mon Sep 17 00:00:00 2001 From: Dratwas Date: Mon, 16 Dec 2019 14:43:20 +0100 Subject: [PATCH 6/7] remove unused file and fix insertion point --- .../add-block-separator/index.native.js | 31 ----------------- .../add-block-separator/style.native.scss | 26 --------------- .../src/components/block-list/index.native.js | 6 ++-- .../block-list/insertion-point.native.js | 33 +++++-------------- .../src/components/inserter/index.native.js | 4 +-- 5 files changed, 14 insertions(+), 86 deletions(-) delete mode 100644 packages/block-editor/src/components/add-block-separator/index.native.js delete mode 100644 packages/block-editor/src/components/add-block-separator/style.native.scss diff --git a/packages/block-editor/src/components/add-block-separator/index.native.js b/packages/block-editor/src/components/add-block-separator/index.native.js deleted file mode 100644 index 705a11dc71bf0d..00000000000000 --- a/packages/block-editor/src/components/add-block-separator/index.native.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * External dependencies - */ -import { Text, View } from 'react-native'; - -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { withPreferredColorScheme } from '@wordpress/compose'; - -/** - * Internal dependencies - */ -import styles from './style.scss'; - -const AddBlockSeparator = ( { getStylesFromColorScheme } ) => { - const lineStyle = getStylesFromColorScheme( styles.lineStyleAddHere, styles.lineStyleAddHereDark ); - const labelStyle = getStylesFromColorScheme( styles.labelStyleAddHere, styles.labelStyleAddHereDark ); - - return ( - - - { __( 'ADD BLOCK HERE' ) } - - - ); -}; - -export default withPreferredColorScheme( AddBlockSeparator ) -; diff --git a/packages/block-editor/src/components/add-block-separator/style.native.scss b/packages/block-editor/src/components/add-block-separator/style.native.scss deleted file mode 100644 index 75b2f85fee9fca..00000000000000 --- a/packages/block-editor/src/components/add-block-separator/style.native.scss +++ /dev/null @@ -1,26 +0,0 @@ -.lineStyleAddHere { - flex: 1; - background-color: #0087be; // blue_wordpress - align-self: center; - height: 2px; -} - -.lineStyleAddHereDark { - background-color: $gray-50; -} - -.labelStyleAddHere { - flex: 1; - text-align: center; - font-family: $default-monospace-font; - font-size: 12px; - font-weight: bold; -} - -.labelStyleAddHereDark { - color: $gray-20; -} - -.containerStyleAddHere { - flex-direction: row; -} diff --git a/packages/block-editor/src/components/block-list/index.native.js b/packages/block-editor/src/components/block-list/index.native.js index 254354df4fcc3f..971b5429c4b86d 100644 --- a/packages/block-editor/src/components/block-list/index.native.js +++ b/packages/block-editor/src/components/block-list/index.native.js @@ -19,7 +19,7 @@ import { KeyboardAwareFlatList, ReadableContentView } from '@wordpress/component import styles from './style.scss'; import BlockListBlock from './block'; import BlockListAppender from '../block-list-appender'; -import AddBlockSeparator from '../add-block-separator'; +import BlockInsertionPoint from './insertion-point'; import __experimentalBlockListFooter from '../block-list-footer'; const innerToolbarHeight = 44; @@ -128,7 +128,7 @@ export class BlockList extends Component { const { shouldShowBlockAtIndex, shouldShowInsertionPointBefore, shouldShowInsertionPointAfter } = this.props; return ( - { shouldShowInsertionPointBefore( clientId ) && } + { shouldShowInsertionPointBefore( clientId ) && } { shouldShowBlockAtIndex( index ) && ( ) } - { shouldShowInsertionPointAfter( clientId ) && } + { shouldShowInsertionPointAfter( clientId ) && } ); } diff --git a/packages/block-editor/src/components/block-list/insertion-point.native.js b/packages/block-editor/src/components/block-list/insertion-point.native.js index d6caa88f407fba..f2d29c887e8415 100644 --- a/packages/block-editor/src/components/block-list/insertion-point.native.js +++ b/packages/block-editor/src/components/block-list/insertion-point.native.js @@ -7,40 +7,25 @@ import { Text, View } from 'react-native'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { withSelect } from '@wordpress/data'; +import { withPreferredColorScheme } from '@wordpress/compose'; /** * Internal dependencies */ import styles from './style.scss'; -const BlockInsertionPoint = ( { showInsertionPoint } ) => { - if ( ! showInsertionPoint ) { - return null; - } +const BlockInsertionPoint = ( { getStylesFromColorScheme } ) => { + const lineStyle = getStylesFromColorScheme( styles.lineStyleAddHere, styles.lineStyleAddHereDark ); + const labelStyle = getStylesFromColorScheme( styles.labelStyleAddHere, styles.labelStyleAddHereDark ); return ( - - { __( 'ADD BLOCK HERE' ) } - + + { __( 'ADD BLOCK HERE' ) } + ); }; -export default withSelect( ( select, { clientId, rootClientId } ) => { - const { - getBlockIndex, - getBlockInsertionPoint, - isBlockInsertionPointVisible, - } = select( 'core/block-editor' ); - const blockIndex = getBlockIndex( clientId, rootClientId ); - const insertionPoint = getBlockInsertionPoint(); - const showInsertionPoint = ( - isBlockInsertionPointVisible() && - insertionPoint.index === blockIndex && - insertionPoint.rootClientId === rootClientId - ); - - return { showInsertionPoint }; -} )( BlockInsertionPoint ); +export default withPreferredColorScheme( BlockInsertionPoint ) +; diff --git a/packages/block-editor/src/components/inserter/index.native.js b/packages/block-editor/src/components/inserter/index.native.js index aa4adeaa2a3746..f84390db1c4069 100644 --- a/packages/block-editor/src/components/inserter/index.native.js +++ b/packages/block-editor/src/components/inserter/index.native.js @@ -13,7 +13,7 @@ import { getUnregisteredTypeHandlerName } from '@wordpress/blocks'; */ import styles from './style.scss'; import InserterMenu from './menu'; -import AddBlockSeparator from '../add-block-separator'; +import BlockInsertionPoint from '../block-list/insertion-point'; const defaultRenderToggle = ( { onToggle, disabled, style } ) => ( ; + return ; } const style = getStylesFromColorScheme( styles.addBlockButton, styles.addBlockButtonDark ); return renderToggle( { onToggle, isOpen, disabled, style } ); From 922071e425efa06de3496aba4355d3caa83144e9 Mon Sep 17 00:00:00 2001 From: Dratwas Date: Tue, 17 Dec 2019 11:04:17 +0100 Subject: [PATCH 7/7] nit: remove unnecessary break line --- .../src/components/block-list/insertion-point.native.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-list/insertion-point.native.js b/packages/block-editor/src/components/block-list/insertion-point.native.js index f2d29c887e8415..a9a27415147836 100644 --- a/packages/block-editor/src/components/block-list/insertion-point.native.js +++ b/packages/block-editor/src/components/block-list/insertion-point.native.js @@ -27,5 +27,4 @@ const BlockInsertionPoint = ( { getStylesFromColorScheme } ) => { ); }; -export default withPreferredColorScheme( BlockInsertionPoint ) -; +export default withPreferredColorScheme( BlockInsertionPoint );