Ticket #28595: 28595.9.patch
File 28595.9.patch, 2.6 KB (added by , 11 years ago) |
---|
-
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
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 ) { … … 526 573 dom.removeClass( views, 'wpview-selection-after' ); 527 574 dom.removeClass( views, 'wpview-cursor-hide' ); 528 575 529 if ( view ) {576 if ( view && editor.selection.isCollapsed() ) { 530 577 if ( className === 'wpview-selection-before' || className === 'wpview-selection-after' ) { 531 578 setViewCursorTries = 0; 532 579