Make WordPress Core

Ticket #31571: 31571.3.patch

File 31571.3.patch, 1.9 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                        range;
     67
     68                if ( editor.selection.isCollapsed() ) {
     69                        return;
     70                }
     71
     72                content = content.replace( /<[^>]+>/g, '' );
     73                content = tinymce.trim( content );
     74
     75                if ( ! /^(?:https?:)?\/\/\S+$/i.test( content ) ) {
     76                        return;
     77                }
     78
     79                range = editor.selection.getRng();
     80
     81                function block( node ) {
     82                        return editor.dom.getParent( node, function( node ) {
     83                                return editor.dom.isBlock( node );
     84                        } );
     85                }
     86
     87                if ( block( range.startContainer ) !== block( range.endContainer ) ) {
     88                        return;
     89                }
     90
     91                editor.execCommand( 'mceInsertLink', false, {
     92                        href: editor.dom.decode( content )
     93                } );
     94
     95                event.preventDefault();
     96        } );
    6397});