diff --git a/packages/block-editor/src/components/rich-text/index.js b/packages/block-editor/src/components/rich-text/index.js index 2d73bed67d5c8..6c5502b223dfc 100644 --- a/packages/block-editor/src/components/rich-text/index.js +++ b/packages/block-editor/src/components/rich-text/index.js @@ -117,6 +117,7 @@ function RichTextWrapper( onRemove, onMerge, onSplit, + onSplitAtEnd, __unstableOnSplitMiddle: onSplitMiddle, identifier, // To do: find a better way to implicitly inherit props. @@ -360,11 +361,17 @@ function RichTextWrapper( } else { onChange( insertLineSeparator( value ) ); } - } else if ( shiftKey || ! canSplit ) { + } else if ( shiftKey ) { if ( ! disableLineBreaks ) { onChange( insert( value, '\n' ) ); } - } else { + } else if ( onSplitAtEnd && ! canSplit ) { + const { text, start, end } = value; + + if ( start === end && end === text.length ) { + onSplitAtEnd(); + } + } else if ( canSplit ) { splitValue( value ); } }, diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 10ea6dbb3a15c..4eab713a47987 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -38,6 +38,7 @@ import { __, sprintf } from '@wordpress/i18n'; import { getPath } from '@wordpress/url'; import { withViewportMatch } from '@wordpress/viewport'; import { image as icon } from '@wordpress/icons'; +import { createBlock } from '@wordpress/blocks'; /** * Internal dependencies @@ -334,6 +335,7 @@ export class ImageEdit extends Component { isRTL, onResizeStart, onResizeStop, + insertBlocksAfter, } = this.props; const { url, @@ -671,6 +673,11 @@ export class ImageEdit extends Component { } isSelected={ this.state.captionFocused } inlineToolbar + onSplitAtEnd={ () => + insertBlocksAfter( + createBlock( 'core/paragraph' ) + ) + } /> ) }