Ticket #28595: 28595.10.patch
File 28595.10.patch, 4.2 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
8 8 VK = tinymce.util.VK, 9 9 TreeWalker = tinymce.dom.TreeWalker, 10 10 toRemove = false, 11 cursorInterval, lastKeyDownNode, setViewCursorTries ;11 cursorInterval, lastKeyDownNode, setViewCursorTries, focus; 12 12 13 13 function getView( node ) { 14 14 return editor.dom.getParent( node, function( node ) { … … 349 349 selection = editor.selection, 350 350 node = selection.getNode(), 351 351 view = getView( node ), 352 cursorBefore, cursorAfter; 352 cursorBefore, cursorAfter, 353 range, clonedRange, tempRange; 353 354 354 355 lastKeyDownNode = node; 355 356 357 // Make sure we don't delete part of a view. 358 // If the range ends or starts with the view, we'll need to trim it. 359 if ( ! selection.isCollapsed() ) { 360 range = selection.getRng(); 361 362 if ( view = getView( range.endContainer ) ) { 363 clonedRange = range.cloneRange(); 364 selection.select( view.previousSibling, true ); 365 selection.collapse(); 366 tempRange = selection.getRng(); 367 clonedRange.setEnd( tempRange.endContainer, tempRange.endOffset ); 368 selection.setRng( clonedRange ); 369 370 return; 371 } else if ( view = getView( range.startContainer ) ) { 372 clonedRange = range.cloneRange(); 373 clonedRange.setStart( view.nextSibling, 0 ); 374 selection.setRng( clonedRange ); 375 376 return; 377 } 378 } 379 356 380 if ( ! view ) { 357 381 return; 358 382 } … … 465 489 return; 466 490 } 467 491 468 if ( keyCode === VK.LEFT || keyCode === VK.UP) {492 if ( keyCode === VK.LEFT ) { 469 493 setViewCursor( true, view ); 470 494 deselect(); 471 } else if ( keyCode === VK.RIGHT || keyCode === VK.DOWN ) { 495 } else if ( keyCode === VK.UP ) { 496 if ( view.previousSibling ) { 497 if ( getView( view.previousSibling ) ) { 498 setViewCursor( true, view.previousSibling ); 499 } else { 500 selection.select( view.previousSibling, true ); 501 selection.collapse(); 502 } 503 } else { 504 handleEnter( view, true ); 505 } 506 deselect(); 507 } else if ( keyCode === VK.RIGHT ) { 472 508 setViewCursor( false, view ); 473 509 deselect(); 510 } else if ( keyCode === VK.DOWN ) { 511 if ( view.nextSibling ) { 512 if ( getView( view.nextSibling ) ) { 513 setViewCursor( false, view.nextSibling ); 514 } else { 515 selection.setCursorLocation( view.nextSibling, 0 ); 516 } 517 } else { 518 handleEnter( view ); 519 } 520 deselect(); 474 521 } else if ( keyCode === VK.ENTER ) { 475 522 handleEnter( view ); 476 523 } else if ( keyCode === VK.DELETE || keyCode === VK.BACKSPACE ) { … … 511 558 } 512 559 }); 513 560 561 editor.on( 'focus', function() { 562 focus = true; 563 editor.dom.addClass( editor.getBody(), 'has-focus' ); 564 } ); 565 566 editor.on( 'blur', function() { 567 focus = false; 568 editor.dom.removeClass( editor.getBody(), 'has-focus' ); 569 } ); 570 514 571 editor.on( 'nodechange', function( event ) { 515 572 var dom = editor.dom, 516 573 views = editor.dom.select( '.wpview-wrap' ), … … 526 583 dom.removeClass( views, 'wpview-selection-after' ); 527 584 dom.removeClass( views, 'wpview-cursor-hide' ); 528 585 529 if ( view ) {586 if ( view && editor.selection.isCollapsed() && focus ) { 530 587 if ( className === 'wpview-selection-before' || className === 'wpview-selection-after' ) { 531 588 setViewCursorTries = 0; 532 589 -
src/wp-includes/js/tinymce/skins/wordpress/wp-content.css
241 241 user-select: text; 242 242 } 243 243 244 . wpview-wrap.wpview-selection-before:before,245 . wpview-wrap.wpview-selection-after:before {244 .has-focus .wpview-wrap.wpview-selection-before:before, 245 .has-focus .wpview-wrap.wpview-selection-after:before { 246 246 content: ''; 247 247 margin: 0; 248 248 padding: 0; … … 258 258 opacity: 1; 259 259 } 260 260 261 . wpview-wrap.wpview-selection-after:before {261 .has-focus .wpview-wrap.wpview-selection-after:before { 262 262 left: auto; 263 263 right: -3px; 264 264 } 265 265 266 . wpview-wrap.wpview-cursor-hide:before {266 .has-focus .wpview-wrap.wpview-cursor-hide:before { 267 267 opacity: 0; 268 268 } 269 269