Make WordPress Core

Ticket #29380: 29380.3.patch

File 29380.3.patch, 2.1 KB (added by iseulde, 9 years ago)
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

     
    1212                firstFocus = true,
    1313                _noop = function() { return false; },
    1414                isios = /iPad|iPod|iPhone/.test( navigator.userAgent ),
    15                 cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView;
     15                cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView, execCommandBefore;
    1616
    1717        function getView( node ) {
    1818                return getParent( node, 'wpview-wrap' );
     
    368368        // Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode
    369369        function isSpecialKey( key ) {
    370370                return ( ( key <= 47 && key !== VK.SPACEBAR && key !== VK.ENTER && key !== VK.DELETE && key !== VK.BACKSPACE && ( key < 37 || key > 40 ) ) ||
    371                         key >= 224 || // OEM or non-printable 
     371                        key >= 224 || // OEM or non-printable
    372372                        ( key >= 144 && key <= 150 ) || // Num Lock, Scroll Lock, OEM
    373373                        ( key >= 91 && key <= 93 ) || // Windows keys
    374374                        ( key >= 112 && key <= 135 ) ); // F keys
     
    649649                var node = editor.selection.getNode(),
    650650                        view;
    651651
    652                 if ( node && ( node.className === 'wpview-selection-before' || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) {
    653                         handleEnter( view );
     652                if ( node && ( ( execCommandBefore = node.className === 'wpview-selection-before' ) || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) {
     653                        handleEnter( view, execCommandBefore );
    654654                        execCommandView = view;
    655655                }
    656656        });
     
    665665                }
    666666
    667667                if ( execCommandView ) {
    668                         node = execCommandView.nextSibling;
     668                        node = execCommandView[ execCommandBefore ? 'previousSibling' : 'nextSibling' ];
    669669
    670670                        if ( node && node.nodeName === 'P' && editor.dom.isEmpty( node ) ) {
    671671                                editor.dom.remove( node );
    672                                 setViewCursor( false, execCommandView );
     672                                setViewCursor( execCommandBefore, execCommandView );
    673673                        }
    674674
    675675                        execCommandView = false;