diff --git a/packages/block-editor/src/components/rich-text/index.js b/packages/block-editor/src/components/rich-text/index.js index b215d21d4344c..3b8bd06ca5ee8 100644 --- a/packages/block-editor/src/components/rich-text/index.js +++ b/packages/block-editor/src/components/rich-text/index.js @@ -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 @@ -129,6 +130,7 @@ class RichTextWrapper extends Component { tagName, canUserUseUnfilteredHTML, multiline, + __unstableEmbedURLOnPaste, } = this.props; if ( image && ! html ) { @@ -151,10 +153,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, } ); diff --git a/packages/block-library/src/paragraph/edit.js b/packages/block-library/src/paragraph/edit.js index c40fae904906f..0d41efd5c2683 100644 --- a/packages/block-library/src/paragraph/edit.js +++ b/packages/block-library/src/paragraph/edit.js @@ -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 /> );