Ticket #7645: 7645_4.patch
File 7645_4.patch, 9.6 KB (added by , 13 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 return; 793 } 794 795 // A fully selected table/list produces a range anchors only at inner boundaries, enlarge it here. (#7645) 796 if ( range.enlarge( CKEDITOR.ENLARGE_LIST_TABLE ) ) 797 range.select(); 798 debugger; 799 } 800 } ); 795 801 796 797 798 if (domDocument.$.compatMode == 'CSS1Compat' )799 800 801 802 803 804 805 806 807 808 809 810 811 802 // PageUp/PageDown scrolling is broken in document 803 // with standard doctype, manually fix it. (#4736) 804 if ( CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat' ) 805 { 806 var pageUpDownKeys = { 33 : 1, 34 : 1 }; 807 domDocument.on( 'keydown', function( evt ) 808 { 809 if ( evt.data.getKeystroke() in pageUpDownKeys ) 810 { 811 setTimeout( function () 812 { 813 editor.getSelection().scrollIntoView(); 814 }, 0 ); 815 } 816 } ); 817 } 812 818 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 ]; 819 // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966) 820 if ( CKEDITOR.env.ie && editor.config.enterMode != CKEDITOR.ENTER_P ) 821 { 822 domDocument.on( 'selectionchange', function() 823 { 824 var body = domDocument.getBody(), 825 range = editor.getSelection().getRanges()[ 0 ]; 819 826 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 827 if ( body.getHtml().match( /^<p> <\/p>$/i ) 828 && range.startContainer.equals( body ) ) 829 { 830 // Avoid the ambiguity from a real user cursor position. 831 setTimeout( function () 832 { 833 range = editor.getSelection().getRanges()[ 0 ]; 834 if ( !range.startContainer.equals ( 'body' ) ) 835 { 836 body.getFirst().remove( 1 ); 837 range.moveToElementEditEnd( body ); 838 range.select( 1 ); 839 } 840 }, 0 ); 841 } 842 }); 836 843 } 837 844 838 845 // Adds the document body as a context menu target. -
_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 … … 1432 1433 sel.addRange( nativeRange ); 1433 1434 } 1434 1435 1436 // Don't miss selection change event for non-IEs. 1437 this.document.fire( 'selectionchange' ); 1435 1438 this.reset(); 1436 1439 } 1437 1440 }, -
_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(), … … 1365 1364 // one and we're expanding list item contents 1366 1365 if ( tailBr ) 1367 1366 this.setEndAfter( tailBr ); 1368 } 1367 break; 1368 1369 case CKEDITOR.ENLARGE_LIST_TABLE: 1370 1371 var ancestor = this.getCommonAncestor( 1, 1 ), 1372 root; 1373 1374 var tags = { table:1,ul:1,ol:1,dl:1}; 1375 for ( var t in tags ) 1376 { 1377 root = ancestor.getAscendant( t, 1 ); 1378 if ( root ) break; 1379 } 1380 1381 if ( !root ) 1382 return false; 1383 1384 // Enlarging the start boundary. 1385 walkerRange = new CKEDITOR.dom.range( this.document ); 1386 walkerRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START ); 1387 walkerRange.setEnd( this.startContainer, this.startOffset ); 1388 1389 var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent ); 1390 walker = new CKEDITOR.dom.walker( walkerRange ), 1391 1392 // Check the range is at the inner boundary of the structural element. 1393 guard = function( walker, isEnd ) 1394 { 1395 return function( node, isWalkOut ) 1396 { 1397 if ( node.type == CKEDITOR.NODE_TEXT && ( !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) ) ) 1398 return true; 1399 1400 var tag; 1401 if ( node.type == CKEDITOR.NODE_ELEMENT ) 1402 { 1403 tag = node.getName(); 1404 1405 // Bypass bogus br at the end of block. 1406 if ( tag == 'br' && isEnd && node.equals( node.getParent().getBogus() ) ) 1407 return true; 1408 1409 if ( isWalkOut && tag in enlargeables || tag in CKEDITOR.dtd.$removeEmpty ) 1410 return true; 1411 } 1412 1413 walker.halted = 1; 1414 return false; 1415 }; 1416 }; 1417 1418 walker.guard = guard( walker ); 1419 1420 if ( walker.checkBackward() && !walker.halted ) 1421 { 1422 walker = new CKEDITOR.dom.walker( walkerRange ); 1423 walkerRange.setStart( this.endContainer, this.endOffset ); 1424 walkerRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END ); 1425 walker.guard = guard( walker, 1 ); 1426 if ( walker.checkForward() && !walker.halted ) 1427 { 1428 this.setStartBefore( root ); 1429 this.setEndAfter( root ); 1430 return true; 1431 } 1432 } 1433 } 1369 1434 }, 1370 1435 1371 1436 /** … … 2035 2100 CKEDITOR.ENLARGE_ELEMENT = 1; 2036 2101 CKEDITOR.ENLARGE_BLOCK_CONTENTS = 2; 2037 2102 CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS = 3; 2103 CKEDITOR.ENLARGE_LIST_TABLE = 4; 2038 2104 2039 2105 // Check boundary types. 2040 2106 // @see CKEDITOR.dom.range.prototype.checkBoundaryOfElement