Ticket #28595: 28595.12.patch
File 28595.12.patch, 5.5 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 } … … 375 399 } 376 400 } 377 401 } else { 378 handleEnter( view, true);402 setViewCursor( true, view ); 379 403 } 380 404 event.preventDefault(); 381 405 } else if ( cursorAfter && ( keyCode === VK.DOWN || keyCode === VK.RIGHT ) ) { 382 406 if ( view.nextSibling ) { 383 407 if ( getView( view.nextSibling ) ) { 384 setViewCursor( false, view.nextSibling );408 setViewCursor( keyCode === VK.RIGHT, view.nextSibling ); 385 409 } else { 386 410 selection.setCursorLocation( view.nextSibling, 0 ); 387 411 } 388 } else {389 handleEnter( view );390 412 } 391 413 event.preventDefault(); 392 414 } else if ( cursorBefore && ( keyCode === VK.UP || keyCode === VK.LEFT ) ) { 393 415 if ( view.previousSibling ) { 394 416 if ( getView( view.previousSibling ) ) { 395 setViewCursor( true, view.previousSibling );417 setViewCursor( keyCode === VK.UP, view.previousSibling ); 396 418 } else { 397 419 selection.select( view.previousSibling, true ); 398 420 selection.collapse(); 399 421 } 400 } else {401 handleEnter( view, true );402 422 } 403 423 event.preventDefault(); 404 424 } else if ( cursorBefore && keyCode === VK.DOWN ) { … … 409 429 selection.setCursorLocation( view.nextSibling, 0 ); 410 430 } 411 431 } else { 412 handleEnter(view );432 setViewCursor( false, view ); 413 433 } 414 434 event.preventDefault(); 415 435 } else if ( ( cursorAfter && keyCode === VK.LEFT ) || ( cursorBefore && keyCode === VK.RIGHT ) ) { … … 465 485 return; 466 486 } 467 487 468 if ( keyCode === VK.LEFT || keyCode === VK.UP) {488 if ( keyCode === VK.LEFT ) { 469 489 setViewCursor( true, view ); 470 490 deselect(); 471 } else if ( keyCode === VK.RIGHT || keyCode === VK.DOWN ) { 491 } else if ( keyCode === VK.UP ) { 492 if ( view.previousSibling ) { 493 if ( getView( view.previousSibling ) ) { 494 setViewCursor( true, view.previousSibling ); 495 } else { 496 selection.select( view.previousSibling, true ); 497 selection.collapse(); 498 } 499 } else { 500 setViewCursor( true, view ); 501 } 502 deselect(); 503 } else if ( keyCode === VK.RIGHT ) { 472 504 setViewCursor( false, view ); 473 505 deselect(); 506 } else if ( keyCode === VK.DOWN ) { 507 if ( view.nextSibling ) { 508 if ( getView( view.nextSibling ) ) { 509 setViewCursor( false, view.nextSibling ); 510 } else { 511 selection.setCursorLocation( view.nextSibling, 0 ); 512 } 513 } else { 514 setViewCursor( false, view ); 515 } 516 deselect(); 474 517 } else if ( keyCode === VK.ENTER ) { 475 518 handleEnter( view ); 476 519 } else if ( keyCode === VK.DELETE || keyCode === VK.BACKSPACE ) { … … 511 554 } 512 555 }); 513 556 557 editor.on( 'focus', function() { 558 focus = true; 559 editor.dom.addClass( editor.getBody(), 'has-focus' ); 560 } ); 561 562 editor.on( 'blur', function() { 563 focus = false; 564 editor.dom.removeClass( editor.getBody(), 'has-focus' ); 565 } ); 566 514 567 editor.on( 'nodechange', function( event ) { 515 568 var dom = editor.dom, 516 569 views = editor.dom.select( '.wpview-wrap' ), … … 526 579 dom.removeClass( views, 'wpview-selection-after' ); 527 580 dom.removeClass( views, 'wpview-cursor-hide' ); 528 581 529 if ( view ) {582 if ( view && editor.selection.isCollapsed() && focus ) { 530 583 if ( className === 'wpview-selection-before' || className === 'wpview-selection-after' ) { 531 584 setViewCursorTries = 0; 532 585 -
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