+
+ editor.on( 'pastepreprocess', function( event ) {
+ var pastedStr = event.content;
+
+ if ( ! editor.selection.isCollapsed() ) {
+ pastedStr = pastedStr.replace( /<[^>]+>/g, '' );
+ pastedStr = tinymce.trim( pastedStr );
+
+ if ( /^(?:https?:)?\/\/\S+$/i.test( pastedStr ) ) {
+ editor.execCommand( 'mceInsertLink', false, {
+ href: editor.dom.decode( pastedStr )
+ } );
+
+ event.preventDefault();
+ }
+ }
+ } );