Make WordPress Core

Ticket #28567: 28567.3.patch

File 28567.3.patch, 6.0 KB (added by iseulde, 11 years ago)
  • src/wp-includes/css/editor.css

     
    169169        margin: 0;
    170170}
    171171
     172.wpview-selected .mce-statusbar .mce-divider,
     173.wpview-selected .mce-statusbar .mce-path-item {
     174        display: none;
     175}
     176
     177.wpview-selected .mce-statusbar .mce-path-item.mce-last {
     178        display: inline-block;
     179        pointer-events: none;
     180}
     181
    172182.mce-toolbar .mce-btn,
    173183.qt-fullscreen {
    174184        border-color: transparent;
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

     
    5555        function setViewCursor( before, view ) {
    5656                var location = before ? 'before' : 'after',
    5757                        offset = before ? 0 : 1;
     58                deselect();
    5859                editor.selection.setCursorLocation( editor.dom.select( '.wpview-selection-' + location, view )[0], offset );
    5960                editor.nodeChanged();
    6061        }
     
    111112                dom.bind( clipboard, 'beforedeactivate focusin focusout', _stop );
    112113                dom.bind( selected, 'beforedeactivate focusin focusout', _stop );
    113114
     115                tinymce.DOM.addClass( editor.getContainer(), 'wpview-selected' );
     116
    114117                // Make sure that the editor is focused.
    115118                // It is possible that the editor is not focused when the mouse event fires
    116119                // without focus, the selection will not work properly.
     
    129132                        dom = editor.dom;
    130133
    131134                if ( selected ) {
    132                         clipboard = editor.dom.select( '.wpview-clipboard', selected )[0];
    133                         dom.unbind( clipboard );
    134                         dom.remove( clipboard );
     135                        if ( clipboard = editor.dom.select( '.wpview-clipboard', selected )[0] ) {
     136                                dom.unbind( clipboard );
     137                                dom.remove( clipboard );
     138                        }
    135139
    136140                        dom.unbind( selected, 'beforedeactivate focusin focusout click mouseup', _stop );
    137141                        dom.setAttrib( selected, 'data-mce-selected', null );
     
    274278                        var view = getView( event.target ),
    275279                                deselectEventType;
    276280
     281                        firstFocus = false;
     282
    277283                        // Contain clicks inside the view wrapper
    278284                        if ( view ) {
    279285                                event.stopPropagation();
     
    484490
    485491                if ( keyCode === VK.LEFT ) {
    486492                        setViewCursor( true, view );
    487                         deselect();
    488493                } else if ( keyCode === VK.UP ) {
    489494                        if ( view.previousSibling ) {
    490495                                if ( getView( view.previousSibling ) ) {
    491496                                        setViewCursor( true, view.previousSibling );
    492497                                } else {
     498                                        deselect();
    493499                                        selection.select( view.previousSibling, true );
    494500                                        selection.collapse();
    495501                                }
    496502                        } else {
    497503                                setViewCursor( true, view );
    498504                        }
    499                         deselect();
     505                       
    500506                } else if ( keyCode === VK.RIGHT ) {
    501507                        setViewCursor( false, view );
    502                         deselect();
    503508                } else if ( keyCode === VK.DOWN ) {
    504509                        if ( view.nextSibling ) {
    505510                                if ( getView( view.nextSibling ) ) {
    506511                                        setViewCursor( false, view.nextSibling );
    507512                                } else {
     513                                        deselect();
    508514                                        selection.setCursorLocation( view.nextSibling, 0 );
    509515                                }
    510516                        } else {
    511517                                setViewCursor( false, view );
    512518                        }
    513                         deselect();
    514519                } else if ( keyCode === VK.ENTER ) {
    515520                        handleEnter( view );
    516521                } else if ( keyCode === VK.DELETE || keyCode === VK.BACKSPACE ) {
     
    586591                dom.removeClass( views, 'wpview-selection-after' );
    587592                dom.removeClass( views, 'wpview-cursor-hide' );
    588593
    589                 if ( view && editor.selection.isCollapsed() && focus ) {
    590                         if ( className === 'wpview-selection-before' || className === 'wpview-selection-after' ) {
    591                                 setViewCursorTries = 0;
    592 
    593                                 // Make sure the cursor arrived in the right node.
    594                                 // This is necessary for Firefox.
    595                                 if ( lKDN === view.previousSibling ) {
    596                                         setViewCursor( true, view );
    597                                         return;
    598                                 } else if ( lKDN === view.nextSibling ) {
    599                                         setViewCursor( false, view );
    600                                         return;
    601                                 }
     594                if ( ! selected ) {
     595                        tinymce.DOM.removeClass( editor.getContainer(), 'wpview-selected' );
     596                }
    602597
    603                                 dom.addClass( view, className );
     598                if ( focus ) {
     599                        if ( view ) {
     600                                if ( className === 'wpview-selection-before' || className === 'wpview-selection-after' && editor.selection.isCollapsed() ) {
     601                                        setViewCursorTries = 0;
    604602
    605                                 cursorInterval = setInterval( function() {
    606                                         if ( dom.hasClass( view, 'wpview-cursor-hide' ) ) {
    607                                                 dom.removeClass( view, 'wpview-cursor-hide' );
    608                                         } else {
    609                                                 dom.addClass( view, 'wpview-cursor-hide' );
     603                                        deselect();
     604
     605                                        tinymce.DOM.addClass( editor.getContainer(), 'wpview-selected' );
     606
     607                                        // Make sure the cursor arrived in the right node.
     608                                        // This is necessary for Firefox.
     609                                        if ( lKDN === view.previousSibling ) {
     610                                                setViewCursor( true, view );
     611                                                return;
     612                                        } else if ( lKDN === view.nextSibling ) {
     613                                                setViewCursor( false, view );
     614                                                return;
    610615                                        }
    611                                 }, 500 );
    612                         // If the cursor happens to be anywhere around the view, then set the cursor properly.
    613                         // Only try this once to prevent a loop. (You never know.)
    614                         } else if ( ! selected && ! setViewCursorTries ) {
    615                                 setViewCursorTries++;
    616                                 setViewCursor( true, view );
     616
     617                                        dom.addClass( view, className );
     618
     619                                        cursorInterval = setInterval( function() {
     620                                                if ( dom.hasClass( view, 'wpview-cursor-hide' ) ) {
     621                                                        dom.removeClass( view, 'wpview-cursor-hide' );
     622                                                } else {
     623                                                        dom.addClass( view, 'wpview-cursor-hide' );
     624                                                }
     625                                        }, 500 );
     626                                // If the cursor lands anywhere else in the view, set the cursor before it.
     627                                // Only try this once to prevent a loop. (You never know.)
     628                                } else if ( className !== 'wpview-clipboard' && ! setViewCursorTries ) {
     629                                        deselect();
     630                                        setViewCursorTries++;
     631                                        setViewCursor( true, view );
     632                                }
     633                        } else {
     634                                deselect();
    617635                        }
    618636                }
    619637        });
    620638
     639        editor.on( 'resolvename', function( event ) {
     640                var className = event.target.className;
     641
     642                if ( className === 'wpview-clipboard' || className === 'wpview-selection-before' || className === 'wpview-selection-after' ) {
     643                        event.name = editor.dom.getAttrib( getView( event.target ), 'data-wpview-type' );
     644                }
     645        });
     646
    621647        return {
    622648                getViewText: getViewText,
    623649                setViewText: setViewText