Skip to content

Commit

Permalink
Enable embed on URL paste in paragraph block
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Aug 22, 2019
1 parent 7793b1d commit 80173db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
import { withFilters, IsolatedEventContainer } from '@wordpress/components';
import { createBlobURL } from '@wordpress/blob';
import deprecated from '@wordpress/deprecated';
import { isURL } from '@wordpress/url';

/**
* Internal dependencies
Expand Down Expand Up @@ -124,6 +125,7 @@ class RichTextWrapper extends Component {
tagName,
canUserUseUnfilteredHTML,
multiline,
__unstableEmbedURLOnPaste,
} = this.props;

if ( image && ! html ) {
Expand All @@ -146,10 +148,20 @@ class RichTextWrapper extends Component {
return;
}

let mode = onReplace && onSplit ? 'AUTO' : 'INLINE';

if (
__unstableEmbedURLOnPaste &&
isEmpty( value ) &&
isURL( plainText.trim() )
) {
mode = 'BLOCKS';
}

const content = pasteHandler( {
HTML: html,
plainText,
mode: onReplace && onSplit ? 'AUTO' : 'INLINE',
mode,
tagName,
canUserUseUnfilteredHTML,
} );
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/paragraph/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class ParagraphBlock extends Component {
onRemove={ onReplace ? () => onReplace( [] ) : undefined }
aria-label={ content ? __( 'Paragraph block' ) : __( 'Empty block; start writing or type forward slash to choose a block' ) }
placeholder={ placeholder || __( 'Start writing or type / to choose a block' ) }
__unstableEmbedURLOnPaste
/>
</>
);
Expand Down

0 comments on commit 80173db

Please sign in to comment.