diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index d8b735fb9d..89bf33a1b4 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -1220,6 +1220,12 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } }); + editor.on( 'beforeexeccommand', function( event ) { + if ( isPlaceholder( editor.selection.getNode() ) ) { + event.preventDefault(); + } + } ); + return { _do_shcode: parseShortcode, _get_shcode: getShortcode diff --git a/src/wp-includes/js/tinymce/plugins/wplink/plugin.js b/src/wp-includes/js/tinymce/plugins/wplink/plugin.js index 8c055857fb..934ee30da5 100644 --- a/src/wp-includes/js/tinymce/plugins/wplink/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wplink/plugin.js @@ -1,7 +1,7 @@ /* global tinymce */ tinymce.PluginManager.add( 'wplink', function( editor ) { var linkButton; - + // Register a command so that it can be invoked by using tinyMCE.activeEditor.execCommand( 'WP_Link' ); editor.addCommand( 'WP_Link', function() { if ( ( ! linkButton || ! linkButton.disabled() ) && typeof window.wpLink !== 'undefined' ) { @@ -60,4 +60,21 @@ tinymce.PluginManager.add( 'wplink', function( editor ) { context: 'insert', prependToContext: true }); + + 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(); + } + } + } ); });