Make WordPress Core

Changeset 29302


Ignore:
Timestamp:
07/26/2014 12:07:55 AM (12 years ago)
Author:
azaozz
Message:

TinyMCE:

  • Fix complex character input in Japanese, Chinese, etc. Was broken in getCursorOffset() in editor-expand.js.
  • Disable auto-scrolling in some edge cases when editor expanding is enabled.

See #28328.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/editor-expand.js

    r29279 r29302  
    125125                $statusBar = $contentWrap.find( '.mce-statusbar' ).filter( ':visible' );
    126126
    127                 // Adjust when switching editor modes.
    128                 editor.on( 'show', function() {
    129                         setTimeout( function() {
    130                                 editor.execCommand( 'wpAutoResize' );
    131                                 adjust();
    132                         }, 300 );
    133                 } );
     127                function getCursorOffset() {
     128                        var node = editor.selection.getNode(),
     129                                view, offset;
     130
     131                        if ( editor.plugins.wpview && ( view = editor.plugins.wpview.getView( node ) ) ) {
     132                                offset = view.getBoundingClientRect();
     133                        } else {
     134                                offset = node.getBoundingClientRect();
     135                        }
     136
     137                        return offset.height ? offset : false;
     138                }
    134139
    135140                // Make sure the cursor is always visible.
    … …  
    151156                        }
    152157
    153                         cursorTop = offset.top + editor.getContentAreaContainer().getElementsByTagName( 'iframe' )[0].getBoundingClientRect().top;
     158                        cursorTop = offset.top + editor.getContentAreaContainer().firstChild.getBoundingClientRect().top;
    154159                        cursorBottom = cursorTop + offset.height;
    155160                        cursorTop = cursorTop - buffer;
    … …  
    158163                        editorBottom = windowHeight - $bottom.outerHeight();
    159164
     165                        // Don't scroll if the node is taller than the visible part of the editor
     166                        if ( editorBottom - editorTop < offset.height ) {
     167                                return;
     168                        }
     169
    160170                        if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) {
    161171                                window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop );
    … …  
    165175                } );
    166176
    167                 function getCursorOffset() {
    168                         var selection = editor.selection,
    169                                 node = selection.getNode(),
    170                                 range = selection.getRng(),
    171                                 view, clone, offset;
    172 
    173                         if ( tinymce.Env.ie && tinymce.Env.ie < 9 ) {
    174                                 return;
    175                         }
    176 
    177                         if ( editor.plugins.wpview && ( view = editor.plugins.wpview.getView( node ) ) ) {
    178                                 offset = view.getBoundingClientRect();
    179                         } else if ( selection.isCollapsed() ) {
    180                                 clone = range.cloneRange();
    181 
    182                                 if ( clone.startContainer.length > 1 ) {
    183                                         if ( clone.startContainer.length > clone.endOffset ) {
    184                                                 clone.setEnd( clone.startContainer, clone.endOffset + 1 );
    185                                         } else {
    186                                                 clone.setStart( clone.startContainer, clone.endOffset - 1 );
    187                                         }
    188 
    189                                         selection.setRng( clone );
    190                                         offset = selection.getRng().getBoundingClientRect();
    191                                         selection.setRng( range );
    192                                 } else {
    193                                         offset = node.getBoundingClientRect();
    194                                 }
    195                         } else {
    196                                 offset = range.getBoundingClientRect();
    197                         }
    198 
    199                         if ( ! offset.height ) {
    200                                 return;
    201                         }
    202 
    203                         return offset;
    204                 }
     177                // Adjust when switching editor modes.
     178                editor.on( 'show', function() {
     179                        setTimeout( function() {
     180                                editor.execCommand( 'wpAutoResize' );
     181                                adjust();
     182                        }, 300 );
     183                } );
    205184
    206185                editor.on( 'hide', function() {
  • trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js

    r29298 r29302  
    287287
    288288                editor.dom.bind( editor.getBody().parentNode, 'mousedown mouseup click', function( event ) {
    289                         var view = getView( event.target ),
    290                                 deselectEventType;
     289                        var view = getView( event.target );
    291290
    292291                        firstFocus = false;
Note: See TracChangeset for help on using the changeset viewer.