Ticket #28567: 28567.3.patch
File 28567.3.patch, 6.0 KB (added by , 11 years ago) |
---|
-
src/wp-includes/css/editor.css
169 169 margin: 0; 170 170 } 171 171 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 172 182 .mce-toolbar .mce-btn, 173 183 .qt-fullscreen { 174 184 border-color: transparent; -
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
55 55 function setViewCursor( before, view ) { 56 56 var location = before ? 'before' : 'after', 57 57 offset = before ? 0 : 1; 58 deselect(); 58 59 editor.selection.setCursorLocation( editor.dom.select( '.wpview-selection-' + location, view )[0], offset ); 59 60 editor.nodeChanged(); 60 61 } … … 111 112 dom.bind( clipboard, 'beforedeactivate focusin focusout', _stop ); 112 113 dom.bind( selected, 'beforedeactivate focusin focusout', _stop ); 113 114 115 tinymce.DOM.addClass( editor.getContainer(), 'wpview-selected' ); 116 114 117 // Make sure that the editor is focused. 115 118 // It is possible that the editor is not focused when the mouse event fires 116 119 // without focus, the selection will not work properly. … … 129 132 dom = editor.dom; 130 133 131 134 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 } 135 139 136 140 dom.unbind( selected, 'beforedeactivate focusin focusout click mouseup', _stop ); 137 141 dom.setAttrib( selected, 'data-mce-selected', null ); … … 274 278 var view = getView( event.target ), 275 279 deselectEventType; 276 280 281 firstFocus = false; 282 277 283 // Contain clicks inside the view wrapper 278 284 if ( view ) { 279 285 event.stopPropagation(); … … 484 490 485 491 if ( keyCode === VK.LEFT ) { 486 492 setViewCursor( true, view ); 487 deselect();488 493 } else if ( keyCode === VK.UP ) { 489 494 if ( view.previousSibling ) { 490 495 if ( getView( view.previousSibling ) ) { 491 496 setViewCursor( true, view.previousSibling ); 492 497 } else { 498 deselect(); 493 499 selection.select( view.previousSibling, true ); 494 500 selection.collapse(); 495 501 } 496 502 } else { 497 503 setViewCursor( true, view ); 498 504 } 499 deselect();505 500 506 } else if ( keyCode === VK.RIGHT ) { 501 507 setViewCursor( false, view ); 502 deselect();503 508 } else if ( keyCode === VK.DOWN ) { 504 509 if ( view.nextSibling ) { 505 510 if ( getView( view.nextSibling ) ) { 506 511 setViewCursor( false, view.nextSibling ); 507 512 } else { 513 deselect(); 508 514 selection.setCursorLocation( view.nextSibling, 0 ); 509 515 } 510 516 } else { 511 517 setViewCursor( false, view ); 512 518 } 513 deselect();514 519 } else if ( keyCode === VK.ENTER ) { 515 520 handleEnter( view ); 516 521 } else if ( keyCode === VK.DELETE || keyCode === VK.BACKSPACE ) { … … 586 591 dom.removeClass( views, 'wpview-selection-after' ); 587 592 dom.removeClass( views, 'wpview-cursor-hide' ); 588 593 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 } 602 597 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; 604 602 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; 610 615 } 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(); 617 635 } 618 636 } 619 637 }); 620 638 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 621 647 return { 622 648 getViewText: getViewText, 623 649 setViewText: setViewText