Changeset 7243 for CKEditor/trunk
- Timestamp:
- 08/30/11 18:45:14 (22 months ago)
- Location:
- CKEditor/trunk
- Files:
-
- 3 edited
-
CHANGES.html (modified) (1 diff)
-
_source/plugins/selection/plugin.js (modified) (3 diffs)
-
_source/plugins/wysiwygarea/plugin.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/trunk/CHANGES.html
r7242 r7243 79 79 <li><a href="http://dev.ckeditor.com/ticket/8246">#8246</a> : Bad editing performance on certain document content.</li> 80 80 <li><a href="http://dev.ckeditor.com/ticket/7912">#7912</a> : Cursor trapped in invisible element after enter key.</li> 81 <li><a href="http://dev.ckeditor.com/ticket/7645">#7645</a> : Full list/table deletion with backspace/delete key.</li> 81 82 <li>Updated the following language files:<ul> 82 83 <li><a href="http://dev.ckeditor.com/ticket/8128">#8128</a> : Italian;</li> -
CKEditor/trunk/_source/plugins/selection/plugin.js
r7235 r7243 464 464 doc.on( 'mouseup', checkSelectionChangeTimeout, editor ); 465 465 doc.on( 'keyup', checkSelectionChangeTimeout, editor ); 466 doc.on( 'selectionchange', checkSelectionChangeTimeout, editor ); 466 467 } 467 468 }); … … 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. … … 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 } -
CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js
r7239 r7243 746 746 keystrokeHandler.attach( domDocument ); 747 747 748 if ( CKEDITOR.env.ie ) 749 { 750 domDocument.getDocumentElement().addClass( domDocument.$.compatMode ); 751 // Override keystrokes which should have deletion behavior 752 // on control types in IE . (#4047) 753 editable && domDocument.on( 'keydown', function( evt ) 754 { 755 var keyCode = evt.data.getKeystroke(); 756 757 // Backspace OR Delete. 758 if ( keyCode in { 8 : 1, 46 : 1 } ) 759 { 760 var sel = editor.getSelection(), 761 control = sel.getSelectedElement(); 762 763 if ( control ) 748 domDocument.getDocumentElement().addClass( domDocument.$.compatMode ); 749 // Override keystroke behaviors. 750 editable && domDocument.on( 'keydown', function( evt ) 751 { 752 var keyCode = evt.data.getKeystroke(); 753 754 // Backspace OR Delete. 755 if ( keyCode in { 8 : 1, 46 : 1 } ) 756 { 757 var sel = editor.getSelection(), 758 selected = sel.getSelectedElement(), 759 range = sel.getRanges()[ 0 ]; 760 761 // Override keystrokes which should have deletion behavior 762 // on fully selected element . (#4047) (#7645) 763 if ( selected ) 764 { 765 // Make undo snapshot. 766 editor.fire( 'saveSnapshot' ); 767 768 // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will 769 // break up the selection, safely manage it here. (#4795) 770 range.moveToPosition( selected, CKEDITOR.POSITION_BEFORE_START ); 771 // Remove the control manually. 772 selected.remove(); 773 range.select(); 774 775 editor.fire( 'saveSnapshot' ); 776 777 evt.data.preventDefault(); 778 return; 779 } 780 } 781 } ); 782 783 // PageUp/PageDown scrolling is broken in document 784 // with standard doctype, manually fix it. (#4736) 785 if ( CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat' ) 786 { 787 var pageUpDownKeys = { 33 : 1, 34 : 1 }; 788 domDocument.on( 'keydown', function( evt ) 789 { 790 if ( evt.data.getKeystroke() in pageUpDownKeys ) 791 { 792 setTimeout( function () 764 793 { 765 // Make undo snapshot. 766 editor.fire( 'saveSnapshot' ); 767 768 // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will 769 // break up the selection, safely manage it here. (#4795) 770 var bookmark = sel.getRanges()[ 0 ].createBookmark(); 771 // Remove the control manually. 772 control.remove(); 773 sel.selectBookmarks( [ bookmark ] ); 774 775 editor.fire( 'saveSnapshot' ); 776 777 evt.data.preventDefault(); 778 } 794 editor.getSelection().scrollIntoView(); 795 }, 0 ); 779 796 } 780 797 } ); 781 782 // PageUp/PageDown scrolling is broken in document 783 // with standard doctype, manually fix it. (#4736) 784 if ( domDocument.$.compatMode == 'CSS1Compat' ) 785 { 786 var pageUpDownKeys = { 33 : 1, 34 : 1 }; 787 domDocument.on( 'keydown', function( evt ) 788 { 789 if ( evt.data.getKeystroke() in pageUpDownKeys ) 798 } 799 800 // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966) 801 if ( CKEDITOR.env.ie && editor.config.enterMode != CKEDITOR.ENTER_P ) 802 { 803 domDocument.on( 'selectionchange', function() 804 { 805 var body = domDocument.getBody(), 806 range = editor.getSelection().getRanges()[ 0 ]; 807 808 if ( body.getHtml().match( /^<p> <\/p>$/i ) 809 && range.startContainer.equals( body ) ) 810 { 811 // Avoid the ambiguity from a real user cursor position. 812 setTimeout( function () 790 813 { 791 setTimeout( function () 814 range = editor.getSelection().getRanges()[ 0 ]; 815 if ( !range.startContainer.equals ( 'body' ) ) 792 816 { 793 editor.getSelection().scrollIntoView(); 794 }, 0 ); 795 } 796 } ); 797 } 798 799 // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966) 800 editor.config.enterMode != CKEDITOR.ENTER_P 801 && domDocument.on( 'selectionchange', function() 802 { 803 var body = domDocument.getBody(), 804 range = editor.getSelection().getRanges()[ 0 ]; 805 806 if ( body.getHtml().match( /^<p> <\/p>$/i ) 807 && range.startContainer.equals( body ) ) 808 { 809 // Avoid the ambiguity from a real user cursor position. 810 setTimeout( function () 811 { 812 range = editor.getSelection().getRanges()[ 0 ]; 813 if ( !range.startContainer.equals ( 'body' ) ) 814 { 815 body.getFirst().remove( 1 ); 816 range.moveToElementEditEnd( body ); 817 range.select( 1 ); 818 } 819 }, 0 ); 820 } 821 }); 817 body.getFirst().remove( 1 ); 818 range.moveToElementEditEnd( body ); 819 range.select( 1 ); 820 } 821 }, 0 ); 822 } 823 }); 822 824 } 823 825
Note: See TracChangeset
for help on using the changeset viewer.
