TinyMCE: when pasting an URL over a selection, insert a link with the URL instead of replacing the selection with it. Props iseulde. Fixes #31571.
git-svn-id: https://develop.svn.wordpress.org/trunk@31691 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
69c449963e
commit
7baa0da965
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue