diff --git a/blocks/library/text/index.js b/blocks/library/text/index.js index b74e8de99a93d0..937b5cca55e705 100644 --- a/blocks/library/text/index.js +++ b/blocks/library/text/index.js @@ -1,11 +1,19 @@ +/** + * External dependencies + */ +import { Fill } from 'react-slot-fill'; + /** * Internal dependencies */ import { registerBlock, query } from 'api'; import Editable from 'components/editable'; +import Inserter from '../../../editor/components/inserter'; const { children } = query; +const DEFAULT_CONTENT =

; + registerBlock( 'core/text', { title: wp.i18n.__( 'Text' ), @@ -18,7 +26,7 @@ registerBlock( 'core/text', { }, defaultAttributes: { - content:

+ content: DEFAULT_CONTENT }, controls: [ @@ -56,9 +64,11 @@ registerBlock( 'core/text', { edit( { attributes, setAttributes, insertBlockAfter, focus, setFocus, mergeWithPrevious } ) { const { content, align } = attributes; + const isEmpty = ( ! content || content === DEFAULT_CONTENT ); - return ( + const editable = ( { setAttributes( { @@ -70,13 +80,31 @@ registerBlock( 'core/text', { style={ align ? { textAlign: align } : null } onSplit={ ( before, after ) => { setAttributes( { content: before } ); - insertBlockAfter( wp.blocks.createBlock( 'core/text', { - content: after - } ) ); + + let afterBlockAttributes; + if ( after ) { + afterBlockAttributes = { content: after }; + } + + insertBlockAfter( wp.blocks.createBlock( + 'core/text', + afterBlockAttributes + ) ); } } onMerge={ mergeWithPrevious } /> ); + + if ( focus && isEmpty ) { + return [ + + + , + editable + ]; + } + + return editable; }, save( { attributes } ) { diff --git a/editor/components/block-mover/index.js b/editor/components/block-mover/index.js index f4e422723e5d33..25c09cbc114228 100644 --- a/editor/components/block-mover/index.js +++ b/editor/components/block-mover/index.js @@ -1,6 +1,7 @@ /** * External dependencies */ +import { Slot } from 'react-slot-fill'; import { connect } from 'react-redux'; import classnames from 'classnames'; import { first, last } from 'lodash'; @@ -14,6 +15,7 @@ import IconButton from 'components/icon-button'; function BlockMover( { onMoveUp, onMoveDown, isFirst, isLast } ) { return (

+