Make WordPress Core

Ticket #31571: 31571.2.patch

File 31571.2.patch, 1.6 KB (added by iseulde, 10 years ago)
  • src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

     
    12201220                }
    12211221        });
    12221222
     1223        editor.on( 'beforeexeccommand', function( event ) {
     1224                if ( isPlaceholder( editor.selection.getNode() ) ) {
     1225                        event.preventDefault();
     1226                }
     1227        } );
     1228
    12231229        return {
    12241230                _do_shcode: parseShortcode,
    12251231                _get_shcode: getShortcode
  • src/wp-includes/js/tinymce/plugins/wplink/plugin.js

     
    11/* global tinymce */
    22tinymce.PluginManager.add( 'wplink', function( editor ) {
    33        var linkButton;
    4        
     4
    55        // Register a command so that it can be invoked by using tinyMCE.activeEditor.execCommand( 'WP_Link' );
    66        editor.addCommand( 'WP_Link', function() {
    77                if ( ( ! linkButton || ! linkButton.disabled() ) && typeof window.wpLink !== 'undefined' ) {
     
    6060                context: 'insert',
    6161                prependToContext: true
    6262        });
     63
     64        editor.on( 'pastepreprocess', function( event ) {
     65                var content = event.content;
     66
     67                if ( ! editor.selection.isCollapsed() ) {
     68                        content = content.replace( /<[^>]+>/g, '' );
     69                        content = tinymce.trim( content );
     70
     71                        if ( /^https?:\/\/\S+$/i.test( content ) ) {
     72                                editor.execCommand( 'mceInsertLink', false, {
     73                                        href: editor.dom.decode( content )
     74                                } );
     75
     76                                event.preventDefault();
     77                        }
     78                }
     79        } );
    6380});