Ticket #7645: 7645_5.patch
File 7645_5.patch, 10.3 KB (added by , 13 years ago) |
---|
-
_source/plugins/tab/plugin.js
46 46 var resultRange = new CKEDITOR.dom.range( editor.document ), 47 47 next = CKEDITOR.tools.tryThese( function() 48 48 { 49 var row = cell.getParent(), 50 next = row.$.cells[ cell.$.cellIndex + ( backward ? - 1 : 1 ) ]; 51 52 // Invalid any empty value. 53 next.parentNode.parentNode; 54 return next; 49 return cell.getParent().$.cells[ cell.$.cellIndex + ( backward ? - 1 : 1 ) ]; 55 50 }, 56 51 function() 57 52 { -
_source/plugins/pastetext/plugin.js
17 17 var clipboardText = CKEDITOR.tools.tryThese( 18 18 function() 19 19 { 20 var clipboardText = window.clipboardData.getData( 'Text' ); 21 if ( !clipboardText ) 22 throw 0; 23 return clipboardText; 20 return window.clipboardData.getData( 'Text' ); 24 21 } 25 22 // Any other approach that's working... 26 23 ); -
_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 range = self.getRanges()[ 0 ], 1154 ancestor = range.getCommonAncestor( 1, 1 ), 1155 tags = { table:1,ul:1,ol:1,dl:1 }; 1156 1157 for ( var t in tags ) 1158 { 1159 if ( root = ancestor.getAscendant( t, 1 ) ) 1160 break; 1161 } 1162 1163 if ( root ) 1164 { 1165 // Enlarging the start boundary. 1166 var testRange = new CKEDITOR.dom.range( this.document ); 1167 testRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START ); 1168 testRange.setEnd( range.startContainer, range.startOffset ); 1169 1170 var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent ), 1171 walker = new CKEDITOR.dom.walker( testRange ), 1172 // Check the range is at the inner boundary of the structural element. 1173 guard = function( walker, isEnd ) 1174 { 1175 return function( node, isWalkOut ) 1176 { 1177 if ( node.type == CKEDITOR.NODE_TEXT && ( !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) ) ) 1178 return true; 1179 1180 var tag; 1181 if ( node.type == CKEDITOR.NODE_ELEMENT ) 1182 { 1183 tag = node.getName(); 1184 1185 // Bypass bogus br at the end of block. 1186 if ( tag == 'br' && isEnd && node.equals( node.getParent().getBogus() ) ) 1187 return true; 1188 1189 if ( isWalkOut && tag in enlargeables || tag in CKEDITOR.dtd.$removeEmpty ) 1190 return true; 1191 } 1192 1193 walker.halted = 1; 1194 return false; 1195 }; 1196 }; 1197 1198 walker.guard = guard( walker ); 1199 1200 if ( walker.checkBackward() && !walker.halted ) 1201 { 1202 walker = new CKEDITOR.dom.walker( testRange ); 1203 testRange.setStart( range.endContainer, range.endOffset ); 1204 testRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END ); 1205 walker.guard = guard( walker, 1 ); 1206 if ( walker.checkForward() && !walker.halted ) 1207 return root.$; 1208 } 1209 } 1210 }, 1148 1211 // Figure it out by checking if there's a single enclosed 1149 1212 // node of the range. 1150 1213 function() … … 1444 1507 sel.addRange( nativeRange ); 1445 1508 } 1446 1509 1510 // Don't miss selection change event for non-IEs. 1511 this.document.fire( 'selectionchange' ); 1447 1512 this.reset(); 1448 1513 } 1449 1514 }, -
_source/core/tools.js
727 727 }, 728 728 729 729 /** 730 * Return the first successfully executed function's return value that730 * Return the first successfully executed function's returned truthy value that 731 731 * doesn't throw any exception. 732 732 */ 733 733 tryThese : function() … … 738 738 var lambda = arguments[i]; 739 739 try 740 740 { 741 returnValue = lambda();742 break;741 if ( returnValue = lambda() ); 742 break; 743 743 } 744 744 catch (e) {} 745 745 }