Ticket #7645: 7645_3.patch
File 7645_3.patch, 10.1 KB (added by , 14 years ago) |
---|
-
_source/plugins/wysiwygarea/plugin.js
759 759 keystrokeHandler.blockedKeystrokes[ 8 ] = !editable; 760 760 keystrokeHandler.attach( domDocument ); 761 761 762 if ( CKEDITOR.env.ie ) 763 { 764 domDocument.getDocumentElement().addClass( domDocument.$.compatMode ); 765 // Override keystrokes which should have deletion behavior 766 // on control types in IE . (#4047) 767 editable && domDocument.on( 'keydown', function( evt ) 768 { 769 var keyCode = evt.data.getKeystroke(); 762 domDocument.getDocumentElement().addClass( domDocument.$.compatMode ); 763 // Override keystroke behaviors. 764 editable && domDocument.on( 'keydown', function( evt ) 765 { 766 var keyCode = evt.data.getKeystroke(); 770 767 771 // Backspace OR Delete. 772 if ( keyCode in { 8 : 1, 46 : 1 } ) 773 { 774 var sel = editor.getSelection(), 775 control = sel.getSelectedElement(); 768 // Backspace OR Delete. 769 if ( keyCode in { 8 : 1, 46 : 1 } ) 770 { 771 var sel = editor.getSelection(), 772 selected = sel.getSelectedElement(), 773 range = sel.getRanges()[ 0 ]; 776 774 777 if ( control ) 778 { 779 // Make undo snapshot. 780 editor.fire( 'saveSnapshot' ); 775 // Override keystrokes which should have deletion behavior 776 // on control types in IE . (#4047) 777 if ( CKEDITOR.env.ie && selected ) 778 { 779 // Make undo snapshot. 780 editor.fire( 'saveSnapshot' ); 781 781 782 783 784 var bookmark = sel.getRanges()[ 0 ].createBookmark();785 786 control.remove();787 782 // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will 783 // break up the selection, safely manage it here. (#4795) 784 var bookmark = range.createBookmark(); 785 // Remove the control manually. 786 selected.remove(); 787 sel.selectBookmarks( [ bookmark ] ); 788 788 789 789 editor.fire( 'saveSnapshot' ); 790 790 791 evt.data.preventDefault(); 792 } 793 } 794 } ); 791 evt.data.preventDefault(); 792 } 793 794 // A fully selected table/list produces a range anchors only at inner boundaries, enlarge it here. (#7645) 795 if ( range.enlarge( CKEDITOR.ENLARGE_LIST_TABLE ) ) 796 range.select(); 797 } 798 } ); 795 799 796 797 798 if (domDocument.$.compatMode == 'CSS1Compat' )799 800 801 802 803 804 805 806 807 808 809 810 811 800 // PageUp/PageDown scrolling is broken in document 801 // with standard doctype, manually fix it. (#4736) 802 if ( CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat' ) 803 { 804 var pageUpDownKeys = { 33 : 1, 34 : 1 }; 805 domDocument.on( 'keydown', function( evt ) 806 { 807 if ( evt.data.getKeystroke() in pageUpDownKeys ) 808 { 809 setTimeout( function () 810 { 811 editor.getSelection().scrollIntoView(); 812 }, 0 ); 813 } 814 } ); 815 } 812 816 813 // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966) 814 editor.config.enterMode != CKEDITOR.ENTER_P 815 && domDocument.on( 'selectionchange', function() 816 { 817 var body = domDocument.getBody(), 818 range = editor.getSelection().getRanges()[ 0 ]; 817 // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966) 818 if ( CKEDITOR.env.ie && editor.config.enterMode != CKEDITOR.ENTER_P ) 819 { 820 domDocument.on( 'selectionchange', function() 821 { 822 var body = domDocument.getBody(), 823 range = editor.getSelection().getRanges()[ 0 ]; 819 824 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 825 if ( body.getHtml().match( /^<p> <\/p>$/i ) 826 && range.startContainer.equals( body ) ) 827 { 828 // Avoid the ambiguity from a real user cursor position. 829 setTimeout( function () 830 { 831 range = editor.getSelection().getRanges()[ 0 ]; 832 if ( !range.startContainer.equals ( 'body' ) ) 833 { 834 body.getFirst().remove( 1 ); 835 range.moveToElementEditEnd( body ); 836 range.select( 1 ); 837 } 838 }, 0 ); 839 } 840 }); 836 841 } 837 842 838 843 // Adds the document body as a context menu target. -
_source/core/dom/walker.js
446 446 // Check if there's a filler node at the end of an element, and return it. 447 447 CKEDITOR.dom.element.prototype.getBogus = function() 448 448 { 449 if ( !this.isBlockBoundary() ) 450 return null; 451 449 452 // Bogus are not always at the end, e.g. <p><a>text<br /></a></p> (#7070). 450 453 var tail = this; 451 454 do { tail = tail.getPreviousSourceNode(); } -
_source/core/dom/range.js
386 386 { 387 387 // Reject any text node unless it's being bookmark 388 388 // OR it's spaces. (#3883) 389 return node.type != CKEDITOR.NODE_TEXT 390 && node.getName() in CKEDITOR.dtd.$removeEmpty 391 || !CKEDITOR.tools.trim( node.getText() ) 392 || !!node.getParent().data( 'cke-bookmark' ); 389 return node.type == CKEDITOR.NODE_TEXT ? 390 !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) 391 : node.getName() in CKEDITOR.dtd.$removeEmpty; 393 392 } 394 393 395 394 var whitespaceEval = new CKEDITOR.dom.walker.whitespaces(), … … 1349 1348 // one and we're expanding list item contents 1350 1349 if ( tailBr ) 1351 1350 this.setEndAfter( tailBr ); 1352 } 1351 break; 1352 1353 case CKEDITOR.ENLARGE_LIST_TABLE: 1354 1355 var ancestor = this.getCommonAncestor( 1, 1 ), 1356 root; 1357 1358 var tags = { table:1,ul:1,ol:1,dl:1}; 1359 for ( var t in tags ) 1360 { 1361 root = ancestor.getAscendant( t, 1 ); 1362 if ( root ) break; 1363 } 1364 1365 if ( !root ) 1366 return false; 1367 1368 // Enlarging the start boundary. 1369 walkerRange = new CKEDITOR.dom.range( this.document ); 1370 walkerRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START ); 1371 walkerRange.setEnd( this.startContainer, this.startOffset ); 1372 1373 var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent ); 1374 walker = new CKEDITOR.dom.walker( walkerRange ), 1375 1376 // Check the range is at the inner boundary of the structural element. 1377 guard = function( walker, isEnd ) 1378 { 1379 return function( node, isWalkOut ) 1380 { 1381 if ( node.type == CKEDITOR.NODE_TEXT && ( !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) ) ) 1382 return true; 1383 1384 var tag; 1385 if ( node.type == CKEDITOR.NODE_ELEMENT ) 1386 { 1387 tag = node.getName(); 1388 1389 // Bypass bogus br at the end of block. 1390 if ( tag == 'br' && isEnd && node.equals( node.getParent().getBogus() ) ) 1391 return true; 1392 1393 if ( isWalkOut && tag in enlargeables || tag in CKEDITOR.dtd.$removeEmpty ) 1394 return true; 1395 } 1396 1397 walker.halted = 1; 1398 return false; 1399 }; 1400 }; 1401 1402 walker.guard = guard( walker ); 1403 1404 if ( walker.checkBackward() && !walker.halted ) 1405 { 1406 walker = new CKEDITOR.dom.walker( walkerRange ); 1407 walkerRange.setStart( this.endContainer, this.endOffset ); 1408 walkerRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END ); 1409 walker.guard = guard( walker, 1 ); 1410 if ( walker.checkForward() && !walker.halted ) 1411 { 1412 this.setStartBefore( root ); 1413 this.setEndAfter( root ); 1414 return true; 1415 } 1416 } 1417 } 1353 1418 }, 1354 1419 1355 1420 /** … … 2019 2084 CKEDITOR.ENLARGE_ELEMENT = 1; 2020 2085 CKEDITOR.ENLARGE_BLOCK_CONTENTS = 2; 2021 2086 CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS = 3; 2087 CKEDITOR.ENLARGE_LIST_TABLE = 4; 2022 2088 2023 2089 // Check boundary types. 2024 2090 // @see CKEDITOR.dom.range.prototype.checkBoundaryOfElement -
_source/plugins/selection/plugin.js
463 463 464 464 doc.on( 'mouseup', checkSelectionChangeTimeout, editor ); 465 465 doc.on( 'keyup', checkSelectionChangeTimeout, editor ); 466 doc.on( 'selectionchange', checkSelectionChangeTimeout, editor ); 466 467 } 467 468 }); 468 469 … … 1395 1396 sel.addRange( nativeRange ); 1396 1397 } 1397 1398 1399 // Don't miss selection change event for non-IEs. 1400 this.document.fire( 'selectionchange' ); 1398 1401 this.reset(); 1399 1402 } 1400 1403 },