From b3664c6f69d4db63024fb22e303a80054bf8280e Mon Sep 17 00:00:00 2001 From: iseulde Date: Thu, 22 Aug 2019 10:46:44 +0200 Subject: [PATCH] Paste: do not force blocks for empty rich text --- .../src/components/rich-text/index.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/index.js b/packages/block-editor/src/components/rich-text/index.js index 25bbcf9b47955d..b215d21d4344c8 100644 --- a/packages/block-editor/src/components/rich-text/index.js +++ b/packages/block-editor/src/components/rich-text/index.js @@ -138,12 +138,11 @@ class RichTextWrapper extends Component { mode: 'BLOCKS', tagName, } ); - const shouldReplace = onReplace && isEmpty( value ); // Allows us to ask for this information when we get a report. window.console.log( 'Received item:\n\n', file ); - if ( shouldReplace ) { + if ( onReplace && isEmpty( value ) ) { onReplace( content ); } else { this.onSplit( value, content ); @@ -152,21 +151,10 @@ class RichTextWrapper extends Component { return; } - const canReplace = onReplace && isEmpty( value ); - const canSplit = onReplace && onSplit; - - let mode = 'INLINE'; - - if ( canReplace ) { - mode = 'BLOCKS'; - } else if ( canSplit ) { - mode = 'AUTO'; - } - const content = pasteHandler( { HTML: html, plainText, - mode, + mode: onReplace && onSplit ? 'AUTO' : 'INLINE', tagName, canUserUseUnfilteredHTML, } ); @@ -182,7 +170,7 @@ class RichTextWrapper extends Component { onChange( insert( value, valueToInsert ) ); } else if ( content.length > 0 ) { - if ( canReplace ) { + if ( onReplace && isEmpty( value ) ) { onReplace( content ); } else { this.onSplit( value, content );