Make WordPress Core

Ticket #28328: 28328.16.patch

File 28328.16.patch, 4.8 KB (added by iseulde, 11 years ago)
  • src/wp-admin/js/editor-expand.js

     
    117117                // Adjust when switching editor modes.
    118118                editor.on( 'show', function() {
    119119                        setTimeout( function() {
    120                                 editor.execCommand( 'mceAutoResize' );
     120                                editor.execCommand( 'wpAutoResize' );
    121121                                adjust( 'resize' );
    122122                        }, 200 );
    123123                } );
    124124
    125                 editor.on( 'keyup', function() {
    126                         var offset = getCursorOffset(),
     125                // Make sure the cursor is always visible.
     126                // This is not only necessary to keep the cursor between the toolbars,
     127                // but also to scroll the window when the cursor moves out of the viewport to a wpview.
     128                // Setting a buffer > 0 will prevent the browser default.
     129                // Some browsers will scroll to the middle,
     130                // others to the top/bottom of the *window* when moving the cursor out of the viewport.
     131                editor.on( 'keyup', function( event ) {
     132                        var VK = tinymce.util.VK,
     133                                key = event.keyCode,
     134                                offset = getCursorOffset(),
    127135                                windowHeight = $window.height(),
     136                                buffer = 10,
    128137                                cursorTop, cursorBottom, editorTop, editorBottom;
    129138
    130139                        if ( ! offset ) {
     
    133142
    134143                        cursorTop = offset.top + editor.getContentAreaContainer().getElementsByTagName( 'iframe' )[0].getBoundingClientRect().top;
    135144                        cursorBottom = cursorTop + offset.height;
     145                        cursorTop = cursorTop - buffer;
     146                        cursorBottom = cursorBottom + buffer;
    136147                        editorTop = $adminBar.outerHeight() + $tools.outerHeight() + $visualTop.outerHeight();
    137                         editorBottom = $window.height() - $bottom.outerHeight();
     148                        editorBottom = windowHeight - $bottom.outerHeight();
    138149
    139                         if ( cursorTop < editorTop || cursorBottom > editorBottom ) {
    140                                 window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - windowHeight / 2 );
     150                        if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT ) ) {
     151                                window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop );
     152                        } else if ( cursorBottom > editorBottom && ( key === VK.DOWN || key === VK.RIGHT ) ) {
     153                                window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom );
    141154                        }
    142155                } );
    143156
     
    145158                        var selection = editor.selection,
    146159                                node = selection.getNode(),
    147160                                range = selection.getRng(),
    148                                 view, clone, right, offset;
     161                                view, clone, offset;
    149162
    150163                        if ( tinymce.Env.ie && tinymce.Env.ie < 9 ) {
    151164                                return;
     
    159172                                if ( clone.startContainer.length > 1 ) {
    160173                                        if ( clone.startContainer.length > clone.endOffset ) {
    161174                                                clone.setEnd( clone.startContainer, clone.endOffset + 1 );
    162                                                 right = true;
    163175                                        } else {
    164176                                                clone.setStart( clone.startContainer, clone.endOffset - 1 );
    165177                                        }
     
    175187                        }
    176188
    177189                        if ( ! offset.height ) {
    178                                 return false;
     190                                return;
    179191                        }
    180192
    181193                        return offset;
  • src/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js

     
    140140                editor.on( 'init', function() {
    141141                        editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
    142142                });
    143                
    144                 editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
    145        
     143
     144                editor.on( 'nodechange keyup FullscreenStateChanged', resize );
     145
     146                editor.on( 'setcontent', function() {
     147                        wait( 3, 100 );
     148                });
     149
    146150                if ( editor.getParam( 'autoresize_on_init', true ) ) {
    147151                        editor.on( 'init', function() {
    148152                                // Hit it 20 times in 100 ms intervals
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

     
    266266                        selection.collapse( true );
    267267                });
    268268
    269                 // When the selection's content changes, scan any new content for matching views.
    270                 // Runs on paste and on inserting nodes/html.
    271                 editor.on( 'SetContent', function( e ) {
    272                         if ( ! e.context ) {
    273                                 return;
    274                         }
    275 
    276                         var node = selection.getNode();
    277 
    278                         if ( ! node.innerHTML ) {
    279                                 return;
    280                         }
    281 
    282                         node.innerHTML = wp.mce.views.toViews( node.innerHTML );
    283                 });
    284 
    285269                editor.dom.bind( editor.getBody().parentNode, 'mousedown mouseup click', function( event ) {
    286270                        var view = getView( event.target ),
    287271                                deselectEventType;
     
    327311        });
    328312
    329313        editor.on( 'PreProcess', function( event ) {
    330                 // Replace the wpview node with the wpview string/shortcode?
     314                // Replace the wpview node with the wpview string/shortcode.
    331315                tinymce.each( editor.dom.select( 'div[data-wpview-text]', event.node ), function( node ) {
    332316                        // Empty the wrap node
    333317                        if ( 'textContent' in node ) {