TinyMCE: wplink: don't link a URL with a pasted URL
Fixes #32357. Built from https://develop.svn.wordpress.org/trunk@32817 git-svn-id: http://core.svn.wordpress.org/trunk@32788 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a31d79196d
commit
c465640107
|
@ -32,13 +32,14 @@ tinymce.PluginManager.add( 'wplink', function( editor ) {
|
|||
});
|
||||
|
||||
editor.on( 'pastepreprocess', function( event ) {
|
||||
var pastedStr = event.content;
|
||||
var pastedStr = event.content,
|
||||
regExp = /^(?:https?:)?\/\/\S+$/i;
|
||||
|
||||
if ( ! editor.selection.isCollapsed() ) {
|
||||
if ( ! editor.selection.isCollapsed() && ! regExp.test( editor.selection.getContent() ) ) {
|
||||
pastedStr = pastedStr.replace( /<[^>]+>/g, '' );
|
||||
pastedStr = tinymce.trim( pastedStr );
|
||||
|
||||
if ( /^(?:https?:)?\/\/\S+$/i.test( pastedStr ) ) {
|
||||
if ( regExp.test( pastedStr ) ) {
|
||||
editor.execCommand( 'mceInsertLink', false, {
|
||||
href: editor.dom.decode( pastedStr )
|
||||
} );
|
||||
|
|
|
@ -1 +1 @@
|
|||
tinymce.PluginManager.add("wplink",function(a){a.addCommand("WP_Link",function(){window.wpLink&&window.wpLink.open(a.id)}),a.addShortcut("Alt+Shift+A","","WP_Link"),a.addShortcut("Meta+K","","WP_Link"),a.addButton("link",{icon:"link",tooltip:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]"}),a.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink"}),a.addMenuItem("link",{icon:"link",text:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0}),a.on("pastepreprocess",function(b){var c=b.content;a.selection.isCollapsed()||(c=c.replace(/<[^>]+>/g,""),c=tinymce.trim(c),/^(?:https?:)?\/\/\S+$/i.test(c)&&(a.execCommand("mceInsertLink",!1,{href:a.dom.decode(c)}),b.preventDefault()))})});
|
||||
tinymce.PluginManager.add("wplink",function(a){a.addCommand("WP_Link",function(){window.wpLink&&window.wpLink.open(a.id)}),a.addShortcut("Alt+Shift+A","","WP_Link"),a.addShortcut("Meta+K","","WP_Link"),a.addButton("link",{icon:"link",tooltip:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]"}),a.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink"}),a.addMenuItem("link",{icon:"link",text:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0}),a.on("pastepreprocess",function(b){var c=b.content,d=/^(?:https?:)?\/\/\S+$/i;a.selection.isCollapsed()||d.test(a.selection.getContent())||(c=c.replace(/<[^>]+>/g,""),c=tinymce.trim(c),d.test(c)&&(a.execCommand("mceInsertLink",!1,{href:a.dom.decode(c)}),b.preventDefault()))})});
|
Binary file not shown.
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.3-alpha-32816';
|
||||
$wp_version = '4.3-alpha-32817';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue