Skip to content

Commit

Permalink
Don't add empty block on paste
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 19, 2020
1 parent 894286b commit 8883940
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,15 @@ function RichTextWrapper(
blocks.push( onSplitMiddle() );
}

// If there's pasted blocks, append a block with the content after the
// caret. Otherwise, do append and empty block if there is no
// `onSplitMiddle` prop, but if there is and the content is empty, the
// middle block is enough to set focus in.
if ( hasPastedBlocks || ! onSplitMiddle || ! isEmpty( after ) ) {
// If there's pasted blocks, append a block with non empty content
/// after the caret. Otherwise, do append and empty block if there
// is no `onSplitMiddle` prop, but if there is and the content is
// empty, the middle block is enough to set focus in.
if (
hasPastedBlocks
? ! isEmpty( after )
: ! onSplitMiddle || ! isEmpty( after )
) {
blocks.push(
onSplit(
toHTMLString( {
Expand Down

0 comments on commit 8883940

Please sign in to comment.