From 88839406936bc08f9720d65a64e43092c53b1053 Mon Sep 17 00:00:00 2001 From: Ella van Durpe Date: Tue, 19 May 2020 14:05:34 +0200 Subject: [PATCH] Don't add empty block on paste --- .../block-editor/src/components/rich-text/index.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/index.js b/packages/block-editor/src/components/rich-text/index.js index 2d1a7eced0730..4b68923c534c8 100644 --- a/packages/block-editor/src/components/rich-text/index.js +++ b/packages/block-editor/src/components/rich-text/index.js @@ -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( {