Ticket #7645: 7645_6.patch
File 7645_6.patch, 8.5 KB (added by , 13 years ago) |
---|
-
_source/plugins/wysiwygarea/plugin.js
749 749 keystrokeHandler.blockedKeystrokes[ 8 ] = !editable; 750 750 keystrokeHandler.attach( domDocument ); 751 751 752 if ( CKEDITOR.env.ie ) 753 { 754 domDocument.getDocumentElement().addClass( domDocument.$.compatMode ); 755 // Override keystrokes which should have deletion behavior 756 // on control types in IE . (#4047) 757 editable && domDocument.on( 'keydown', function( evt ) 758 { 759 var keyCode = evt.data.getKeystroke(); 752 domDocument.getDocumentElement().addClass( domDocument.$.compatMode ); 753 // Override keystroke behaviors. 754 editable && domDocument.on( 'keydown', function( evt ) 755 { 756 var keyCode = evt.data.getKeystroke(); 760 757 761 // Backspace OR Delete. 762 if ( keyCode in { 8 : 1, 46 : 1 } ) 763 { 764 var sel = editor.getSelection(), 765 control = sel.getSelectedElement(); 758 // Backspace OR Delete. 759 if ( keyCode in { 8 : 1, 46 : 1 } ) 760 { 761 var sel = editor.getSelection(), 762 selected = sel.getSelectedElement(), 763 range = sel.getRanges()[ 0 ]; 766 764 767 if ( control ) 768 { 769 // Make undo snapshot. 770 editor.fire( 'saveSnapshot' ); 765 // Override keystrokes which should have deletion behavior 766 // on fully selected element . (#4047) (#7645) 767 if ( selected ) 768 { 769 // Make undo snapshot. 770 editor.fire( 'saveSnapshot' ); 771 771 772 773 774 var bookmark = sel.getRanges()[ 0 ].createBookmark();775 776 control.remove();777 sel.selectBookmarks( [ bookmark ]);772 // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will 773 // break up the selection, safely manage it here. (#4795) 774 range.moveToPosition( selected, CKEDITOR.POSITION_BEFORE_START ); 775 // Remove the control manually. 776 selected.remove(); 777 range.select(); 778 778 779 779 editor.fire( 'saveSnapshot' ); 780 780 781 evt.data.preventDefault(); 782 } 783 } 784 } ); 781 evt.data.preventDefault(); 782 return; 783 } 784 } 785 } ); 785 786 786 787 788 if (domDocument.$.compatMode == 'CSS1Compat' )789 790 791 792 793 794 795 796 797 798 799 800 801 787 // PageUp/PageDown scrolling is broken in document 788 // with standard doctype, manually fix it. (#4736) 789 if ( CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat' ) 790 { 791 var pageUpDownKeys = { 33 : 1, 34 : 1 }; 792 domDocument.on( 'keydown', function( evt ) 793 { 794 if ( evt.data.getKeystroke() in pageUpDownKeys ) 795 { 796 setTimeout( function () 797 { 798 editor.getSelection().scrollIntoView(); 799 }, 0 ); 800 } 801 } ); 802 } 802 803 803 // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966) 804 editor.config.enterMode != CKEDITOR.ENTER_P 805 && domDocument.on( 'selectionchange', function() 806 { 807 var body = domDocument.getBody(), 808 range = editor.getSelection().getRanges()[ 0 ]; 804 // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966) 805 if ( CKEDITOR.env.ie && editor.config.enterMode != CKEDITOR.ENTER_P ) 806 { 807 domDocument.on( 'selectionchange', function() 808 { 809 var body = domDocument.getBody(), 810 range = editor.getSelection().getRanges()[ 0 ]; 809 811 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 812 if ( body.getHtml().match( /^<p> <\/p>$/i ) 813 && range.startContainer.equals( body ) ) 814 { 815 // Avoid the ambiguity from a real user cursor position. 816 setTimeout( function () 817 { 818 range = editor.getSelection().getRanges()[ 0 ]; 819 if ( !range.startContainer.equals ( 'body' ) ) 820 { 821 body.getFirst().remove( 1 ); 822 range.moveToElementEditEnd( body ); 823 range.select( 1 ); 824 } 825 }, 0 ); 826 } 827 }); 826 828 } 827 829 828 830 // 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 … … 1145 1146 { 1146 1147 return self.getNative().createRange().item( 0 ); 1147 1148 }, 1149 // If a table or list is fully selected. 1150 function() 1151 { 1152 var root, 1153 retval, 1154 range = self.getRanges()[ 0 ], 1155 ancestor = range.getCommonAncestor( 1, 1 ), 1156 tags = { table:1,ul:1,ol:1,dl:1 }; 1157 1158 for ( var t in tags ) 1159 { 1160 if ( root = ancestor.getAscendant( t, 1 ) ) 1161 break; 1162 } 1163 1164 if ( root ) 1165 { 1166 // Enlarging the start boundary. 1167 var testRange = new CKEDITOR.dom.range( this.document ); 1168 testRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START ); 1169 testRange.setEnd( range.startContainer, range.startOffset ); 1170 1171 var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent ), 1172 walker = new CKEDITOR.dom.walker( testRange ), 1173 // Check the range is at the inner boundary of the structural element. 1174 guard = function( walker, isEnd ) 1175 { 1176 return function( node, isWalkOut ) 1177 { 1178 if ( node.type == CKEDITOR.NODE_TEXT && ( !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) ) ) 1179 return true; 1180 1181 var tag; 1182 if ( node.type == CKEDITOR.NODE_ELEMENT ) 1183 { 1184 tag = node.getName(); 1185 1186 // Bypass bogus br at the end of block. 1187 if ( tag == 'br' && isEnd && node.equals( node.getParent().getBogus() ) ) 1188 return true; 1189 1190 if ( isWalkOut && tag in enlargeables || tag in CKEDITOR.dtd.$removeEmpty ) 1191 return true; 1192 } 1193 1194 walker.halted = 1; 1195 return false; 1196 }; 1197 }; 1198 1199 walker.guard = guard( walker ); 1200 1201 if ( walker.checkBackward() && !walker.halted ) 1202 { 1203 walker = new CKEDITOR.dom.walker( testRange ); 1204 testRange.setStart( range.endContainer, range.endOffset ); 1205 testRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END ); 1206 walker.guard = guard( walker, 1 ); 1207 if ( walker.checkForward() && !walker.halted ) 1208 retval = root.$; 1209 } 1210 } 1211 1212 if ( !retval ) 1213 throw 0; 1214 1215 return retval; 1216 }, 1148 1217 // Figure it out by checking if there's a single enclosed 1149 1218 // node of the range. 1150 1219 function() … … 1444 1513 sel.addRange( nativeRange ); 1445 1514 } 1446 1515 1516 // Don't miss selection change event for non-IEs. 1517 this.document.fire( 'selectionchange' ); 1447 1518 this.reset(); 1448 1519 } 1449 1520 },