Ticket #28595: 28595.8.patch
File 28595.8.patch, 2.7 KB (added by , 10 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 console.log( range.setStartAfter ); 364 clonedRange = range.cloneRange(); 365 console.log( clonedRange.setStartAfter ); 366 selection.select( view.previousSibling, true ); 367 selection.collapse(); 368 tempRange = selection.getRng(); 369 clonedRange.setEnd( tempRange.endContainer, tempRange.endOffset ); 370 selection.setRng( clonedRange ); 371 372 return; 373 } else if ( view = getView( range.startContainer ) ) { 374 clonedRange = range.cloneRange(); 375 clonedRange.setStart( view.nextSibling, 0 ); 376 selection.setRng( clonedRange ); 377 378 return; 379 } 380 } 381 356 382 if ( ! view ) { 357 383 return; 358 384 } … … 465 491 return; 466 492 } 467 493 468 if ( keyCode === VK.LEFT || keyCode === VK.UP) {494 if ( keyCode === VK.LEFT ) { 469 495 setViewCursor( true, view ); 470 496 deselect(); 471 } else if ( keyCode === VK.RIGHT || keyCode === VK.DOWN ) { 497 } else if ( keyCode === VK.UP ) { 498 if ( view.previousSibling ) { 499 if ( getView( view.previousSibling ) ) { 500 setViewCursor( true, view.previousSibling ); 501 } else { 502 selection.select( view.previousSibling, true ); 503 selection.collapse(); 504 } 505 } else { 506 handleEnter( view, true ); 507 } 508 deselect(); 509 } else if ( keyCode === VK.RIGHT ) { 472 510 setViewCursor( false, view ); 473 511 deselect(); 512 } else if ( keyCode === VK.DOWN ) { 513 if ( view.nextSibling ) { 514 if ( getView( view.nextSibling ) ) { 515 setViewCursor( false, view.nextSibling ); 516 } else { 517 selection.setCursorLocation( view.nextSibling, 0 ); 518 } 519 } else { 520 handleEnter( view ); 521 } 522 deselect(); 474 523 } else if ( keyCode === VK.ENTER ) { 475 524 handleEnter( view ); 476 525 } else if ( keyCode === VK.DELETE || keyCode === VK.BACKSPACE ) { … … 526 575 dom.removeClass( views, 'wpview-selection-after' ); 527 576 dom.removeClass( views, 'wpview-cursor-hide' ); 528 577 529 if ( view ) {578 if ( view && editor.selection.isCollapsed() ) { 530 579 if ( className === 'wpview-selection-before' || className === 'wpview-selection-after' ) { 531 580 setViewCursorTries = 0; 532 581