Skip to content

Commit

Permalink
Paste: do not force blocks for empty rich text
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Sep 4, 2019
1 parent 85eaee3 commit b3664c6
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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,
} );
Expand All @@ -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 );
Expand Down

0 comments on commit b3664c6

Please sign in to comment.