Ticket #3001: 3001_2.patch
File 3001_2.patch, 23.2 KB (added by , 15 years ago) |
---|
-
_source/plugins/pastetext/plugin.js
23 23 } 24 24 25 25 // Check if the selection is inside the editing area for IE. (#3216) 26 if ( !editor.getSelection())26 if ( CKEDITOR.env.ie ) 27 27 editor.focus(); 28 28 29 29 editor.insertText( window.clipboardData.getData( 'Text' ) ); -
_source/plugins/image/dialogs/image.js
314 314 // Insert a new Image. 315 315 if ( !this.imageEditMode ) 316 316 { 317 // It doesn't work with IE.318 this.restoreSelection();319 this.clearSavedSelection();320 321 317 if ( this.addLink ) 322 318 { 323 319 //Insert a new Link. -
_source/plugins/colorbutton/plugin.js
12 12 var config = editor.config, 13 13 lang = editor.lang.colorButton; 14 14 15 var saveRanges, 16 clickFn; 15 var clickFn; 17 16 18 17 addButton( 'TextColor', 'fore', lang.textColorTitle ); 19 18 addButton( 'BGColor', 'back', lang.bgColorTitle ); … … 44 43 keys[ 37 ] = 'prev'; // ARROW-LEFT 45 44 keys[ CKEDITOR.SHIFT + 9 ] = 'prev'; // SHIFT + TAB 46 45 keys[ 32 ] = 'click'; // SPACE 47 },48 49 onOpen : function()50 {51 if ( CKEDITOR.env.ie )52 {53 editor.focus();54 saveRanges = editor.getSelection().getRanges();55 }56 },57 58 onClose : function()59 {60 saveRanges = null;61 46 } 62 47 }); 63 48 } … … 81 66 82 67 editor.focus(); 83 68 84 if ( saveRanges )85 {86 editor.getSelection().selectRanges( saveRanges );87 saveRanges = false;88 }89 90 69 panel.hide(); 91 70 92 71 var style = new CKEDITOR.style( config['colorButton_' + type + 'Style'], { color : color || '#000' } ); -
_source/plugins/wysiwygarea/plugin.js
21 21 data = this.dataProcessor.toHtml( data ); 22 22 23 23 if ( CKEDITOR.env.ie ) 24 { 25 if ( $doc.selection.type == 'Control' ) 26 $doc.selection.clear(); 24 27 $doc.selection.createRange().pasteHTML( data ); 28 } 25 29 else 26 30 $doc.execCommand( 'inserthtml', false, data ); 27 31 } -
_source/plugins/find/dialogs/find.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 798 798 if ( finder.range && finder.range.isMatched() ) 799 799 { 800 800 finder.range.removeHighlight(); 801 editor.focus(); 801 802 editor.getSelection().selectRanges( 802 803 [ finder.range.toDomRange() ] ); 803 804 } -
_source/plugins/selection/plugin.js
10 10 // The selection change check basically saves the element parent tree of 11 11 // the current node and check it on successive requests. If there is any 12 12 // change on the tree, then the selectionChange event gets fired. 13 var checkSelectionChange = function()13 function checkSelectionChange() 14 14 { 15 15 // In IE, the "selectionchange" event may still get thrown when 16 16 // releasing the WYSIWYG mode, so we need to check it first. … … 28 28 } 29 29 }; 30 30 31 var checkSelectionChangeTimer; 32 var checkSelectionChangeTimeoutPending; 33 var checkSelectionChangeTimeout = function() 31 var checkSelectionChangeTimer, 32 checkSelectionChangeTimeoutPending; 33 34 function checkSelectionChangeTimeout() 34 35 { 35 36 // Firing the "OnSelectionChange" event on every key press started to 36 37 // be too slow. This function guarantees that there will be at least … … 44 45 checkSelectionChangeTimeoutExec.call( this ); 45 46 46 47 checkSelectionChangeTimer = CKEDITOR.tools.setTimeout( checkSelectionChangeTimeoutExec, 200, this ); 47 } ;48 } 48 49 49 var checkSelectionChangeTimeoutExec = function()50 function checkSelectionChangeTimeoutExec() 50 51 { 51 52 checkSelectionChangeTimer = null; 52 53 … … 60 61 61 62 checkSelectionChangeTimeoutPending = false; 62 63 } 63 } ;64 } 64 65 65 66 // #### checkSelectionChange : END 66 67 … … 85 86 { 86 87 editor.on( 'contentDom', function() 87 88 { 89 var doc = editor.document; 90 88 91 if ( CKEDITOR.env.ie ) 89 92 { 93 // Other browsers don't loose the selection if the 94 // editor document loose the focus. In IE, we don't 95 // have support for it, so we reproduce it here, other 96 // than firing the selection change event. 97 98 var savedRange, 99 saveEnabled; 100 101 // "onfocusin" is fired before "onfocus". It makes it 102 // possible to restore the selection before click 103 // events get executed. 104 doc.on( 'focusin', function() 105 { 106 // If we have saved a range, restore it at this 107 // point. 108 if ( savedRange ) 109 { 110 // Well not break because of this. 111 try 112 { 113 savedRange.select(); 114 } 115 catch (e) 116 {} 117 118 savedRange = null; 119 } 120 }); 121 122 editor.window.on( 'focus', function() 123 { 124 // Enable selections to be saved. 125 saveEnabled = true; 126 127 saveSelection(); 128 }); 129 130 editor.window.on( 'blur', function() 131 { 132 // Disable selections from being saved. 133 saveEnabled = false; 134 135 // IE may leave the selection still inside the 136 // document. Let's force it to be removed. 137 // TODO: The following has effect for 138 // collapsed selections. 139 editor.document.$.execCommand( 'Unselect' ); 140 }); 141 142 // IE fires the "selectionchange" event when clicking 143 // inside a selection. We don't want to capture that. 144 doc.on( 'mousedown', disableSave ); 145 doc.on( 'mouseup', 146 function() 147 { 148 saveEnabled = true; 149 setTimeout( function() 150 { 151 saveSelection( true ); 152 }, 153 0 ); 154 }); 155 156 doc.on( 'keydown', disableSave ); 157 doc.on( 'keyup', 158 function() 159 { 160 saveEnabled = true; 161 saveSelection(); 162 }); 163 164 90 165 // IE is the only to provide the "selectionchange" 91 166 // event. 92 editor.document.on( 'selectionchange', checkSelectionChangeTimeout, editor ); 167 doc.on( 'selectionchange', saveSelection ); 168 169 function disableSave() 170 { 171 saveEnabled = false; 172 } 173 174 function saveSelection( testIt ) 175 { 176 if ( saveEnabled ) 177 { 178 var doc = editor.document, 179 sel = doc && doc.$.selection; 180 181 // There is a very specific case, when clicking 182 // inside a text selection. In that case, the 183 // selection collapses at the clicking point, 184 // but the selection object remains in an 185 // unknown state, making createRange return a 186 // range at the very start of the document. In 187 // such situation we have to test the range, to 188 // be sure it's valid. 189 if ( testIt && sel && sel.type == 'None' ) 190 { 191 // The "InsertImage" command can be used to 192 // test whether the selection is good or not. 193 // If not, it's enough to give some time to 194 // IE to put things in order for us. 195 if ( !doc.$.queryCommandEnabled( 'InsertImage' ) ) 196 { 197 CKEDITOR.tools.setTimeout( saveSelection, 50, this, true ); 198 return; 199 } 200 } 201 202 savedRange = sel && sel.createRange(); 203 204 checkSelectionChangeTimeout.call( editor ); 205 } 206 } 207 208 editor.lockSelection = function() 209 { 210 saveEnabled = false; 211 }; 212 213 editor.unlockSelection = function() 214 { 215 saveEnabled = true; 216 saveSelection( true ); 217 }; 93 218 } 94 219 else 95 220 { … … 97 222 // check based on other events, like clicks or keys 98 223 // press. 99 224 100 editor.document.on( 'mouseup', checkSelectionChangeTimeout, editor );101 editor.document.on( 'keyup', checkSelectionChangeTimeout, editor );225 doc.on( 'mouseup', checkSelectionChangeTimeout, editor ); 226 doc.on( 'keyup', checkSelectionChangeTimeout, editor ); 102 227 } 103 228 }); 104 229 -
_source/plugins/forms/dialogs/checkbox.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 38 38 this.commitContent( element ); 39 39 40 40 if ( isInsertMode ) 41 {42 this.restoreSelection();43 this.clearSavedSelection();44 41 editor.insertElement( element ); 45 }46 42 }, 47 43 contents : [ 48 44 { … … 60 56 setup : function( element ) 61 57 { 62 58 this.setValue( element.getAttribute( 'name' ) ); 63 this.focus();64 59 }, 65 60 commit : function( element ) 66 61 { -
_source/plugins/forms/dialogs/textfield.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 36 36 this.commitContent( element ); 37 37 38 38 if ( isInsertMode ) 39 {40 this.restoreSelection();41 this.clearSavedSelection();42 39 editor.insertElement( element ); 43 }44 40 }, 45 41 contents : [ 46 42 { -
_source/plugins/forms/dialogs/button.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 39 39 this.commitContent( element ); 40 40 41 41 if ( isInsertMode ) 42 {43 this.restoreSelection();44 this.clearSavedSelection();45 42 editor.insertElement( element ); 46 }47 43 }, 48 44 contents : [ 49 45 { -
_source/plugins/forms/dialogs/textarea.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 35 35 this.commitContent( element ); 36 36 37 37 if ( isInsertMode ) 38 {39 this.restoreSelection();40 this.clearSavedSelection();41 38 editor.insertElement( element ); 42 }43 39 }, 44 40 contents : [ 45 41 { -
_source/plugins/forms/dialogs/radio.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 36 36 this.commitContent( element ); 37 37 38 38 if ( isInsertMode ) 39 {40 this.restoreSelection();41 this.clearSavedSelection();42 39 editor.insertElement( element ); 43 }44 40 }, 45 41 contents : [ 46 42 { -
_source/plugins/forms/dialogs/hiddenfield.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 36 36 this.commitContent( element ); 37 37 38 38 if ( isInsertMode ) 39 {40 this.restoreSelection();41 this.clearSavedSelection();42 39 editor.insertElement( element ); 43 }44 40 }, 45 41 contents : [ 46 42 { -
_source/plugins/forms/dialogs/select.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 163 163 this.commitContent( element ); 164 164 165 165 if ( isInsertMode ) 166 {167 this.restoreSelection();168 this.clearSavedSelection();169 166 editor.insertElement( element ); 170 }171 167 }, 172 168 contents : [ 173 169 { -
_source/plugins/forms/dialogs/form.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 36 36 this.commitContent( element ); 37 37 38 38 if ( isInsertMode ) 39 {40 this.restoreSelection();41 this.clearSavedSelection();42 39 editor.insertElement( element ); 43 }44 40 }, 45 41 contents : [ 46 42 { -
_source/plugins/table/dialogs/table.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 246 246 247 247 // Insert the table element if we're creating one. 248 248 if ( !this._.selectedElement ) 249 {250 this.restoreSelection();251 249 editor.insertElement( table ); 252 this.clearSavedSelection();253 }254 250 255 251 return true; 256 252 }, -
_source/plugins/format/plugin.js
12 12 var config = editor.config, 13 13 lang = editor.lang.format; 14 14 15 var saveRanges;16 17 15 // Gets the list of tags from the settings. 18 16 var tags = config.format_tags.split( ';' ); 19 17 … … 53 51 onClick : function( value ) 54 52 { 55 53 editor.focus(); 56 57 if ( saveRanges )58 {59 editor.getSelection().selectRanges( saveRanges );60 saveRanges = false;61 }62 63 54 styles[ value ].apply( editor.document ); 64 55 }, 65 56 … … 85 76 this.setValue( '' ); 86 77 }, 87 78 this); 88 },89 90 onOpen : function()91 {92 if ( CKEDITOR.env.ie )93 {94 editor.focus();95 saveRanges = editor.getSelection().getRanges();96 }97 },98 99 onClose : function()100 {101 saveRanges = null;102 79 } 103 80 }); 104 81 } -
_source/plugins/link/dialogs/anchor.js
45 45 var fakeElement = editor.createFakeElement( element, 'cke_anchor', 'anchor' ); 46 46 if ( !this.editMode ) 47 47 { 48 // It doesn't work with IE.49 this.restoreSelection();50 this.clearSavedSelection();51 52 48 editor.insertElement( fakeElement ); 53 49 } 54 50 else 51 { 55 52 fakeElement.replace( this.fakeObj ); 53 54 editor.focus(); 55 editor.getSelection().selectElement( fakeElement ); 56 } 57 56 58 return true; 57 59 }, 58 60 onShow : function() … … 79 81 element = editor.restoreRealElement( this.fakeObj ); 80 82 loadElements.apply( this, [ editor, selection, ranges, element ] ); 81 83 selection.selectElement( this.fakeObj ); 82 this.saveSelection();84 editor.saveSelection(); 83 85 } 84 86 } 85 87 this.getContentElement( 'info', 'txtName' ).focus(); -
_source/plugins/flash/dialogs/flash.js
279 279 if ( this.fakeImage ) 280 280 newFakeImage.replace( this.fakeImage ); 281 281 else 282 {283 this.restoreSelection();284 282 editor.insertElement( newFakeImage ); 285 }286 283 }, 287 284 contents : [ 288 285 { -
_source/plugins/dialog/plugin.js
527 527 */ 528 528 show : function() 529 529 { 530 this._.editor.lockSelection(); 531 530 532 // Insert the dialog's element to the root document. 531 533 var element = this._.element; 532 534 var definition = this.definition; … … 679 681 CKEDITOR.document.removeListener( 'keyup', accessKeyUpHandler ); 680 682 681 683 // Restore focus and (if not already restored) selection in the editing area. 682 this.restoreSelection();683 684 this._.editor.focus(); 685 this._.editor.unlockSelection(); 684 686 } 685 687 else 686 688 CKEDITOR.dialog._.currentZIndex -= 10; … … 977 979 */ 978 980 restoreSelection : function() 979 981 { 980 if ( this._.editor.mode && this._.selectedRanges ) 981 ( new CKEDITOR.dom.selection( this._.editor.document ) ).selectRanges( this._.selectedRanges ); 982 this._.editor.focus(); 983 // if ( this._.editor.mode && this._.selectedRanges ) 984 // ( new CKEDITOR.dom.selection( this._.editor.document ) ).selectRanges( this._.selectedRanges ); 982 985 } 983 986 }; 984 987 -
_source/plugins/smiley/dialogs/smiley.js
54 54 else if ( targetName != 'img' ) 55 55 return; 56 56 57 this.getDialog().restoreSelection();58 59 57 var src = target.getAttribute( 'src' ), 60 58 title = target.getAttribute( 'title' ); 61 59 -
_source/plugins/stylescombo/plugin.js
1 /*1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ … … 14 14 var config = editor.config, 15 15 lang = editor.lang.stylesCombo, 16 16 pluginPath = this.path, 17 styles, 18 saveRanges; 17 styles; 19 18 20 19 editor.ui.addRichCombo( 'Styles', 21 20 { … … 97 96 var style = styles[ value ], 98 97 selection = editor.getSelection(); 99 98 100 if ( saveRanges )101 {102 selection.selectRanges( saveRanges );103 saveRanges = false;104 }105 106 99 if ( style.type == CKEDITOR.STYLE_OBJECT ) 107 100 { 108 101 var element = selection.getSelectedElement(); … … 159 152 160 153 var selection = editor.getSelection(); 161 154 162 if ( CKEDITOR.env.ie && selection )163 saveRanges = selection.getRanges();164 165 155 var elementPath, 166 156 element = selection.getSelectedElement(), 167 157 elementName = element && element.getName(), … … 218 208 219 209 if ( !counter[ CKEDITOR.STYLE_OBJECT ] ) 220 210 this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_OBJECT ) ] ); 221 },222 223 onClose : function()224 {225 saveRanges = null;226 211 } 227 212 }); 228 213 } -
_source/plugins/font/plugin.js
8 8 function addCombo( editor, comboName, styleType, lang, entries, defaultLabel, styleDefinition ) 9 9 { 10 10 var config = editor.config; 11 var saveRanges;12 11 13 12 // Gets the list of fonts from the settings. 14 13 var names = entries.split( ';' ), … … 56 55 { 57 56 editor.focus(); 58 57 59 if ( saveRanges )60 {61 editor.getSelection().selectRanges( saveRanges );62 saveRanges = false;63 }64 65 58 var style = styles[ value ]; 66 59 67 60 if ( this.getValue() == value ) … … 101 94 this.setValue( '', defaultLabel ); 102 95 }, 103 96 this); 104 },105 106 onOpen : function()107 {108 if ( CKEDITOR.env.ie )109 {110 editor.focus();111 saveRanges = editor.getSelection().getRanges();112 }113 },114 115 onClose : function()116 {117 saveRanges = null;118 97 } 119 98 }); 120 99 } -
_source/plugins/contextmenu/plugin.js
60 60 if ( item.onClick ) 61 61 item.onClick(); 62 62 else if ( item.command ) 63 {64 if ( CKEDITOR.env.ie )65 this.restoreSelection();66 67 63 editor.execCommand( item.command ); 68 }69 64 }, this ); 70 65 71 66 menu.onEscape = function() -
_source/core/command.js
10 10 if ( this.state == CKEDITOR.TRISTATE_DISABLED ) 11 11 return false; 12 12 13 // The editor will always have the focus when executing a command. 14 editor.focus(); 15 13 16 return ( commandDefinition.exec.call( this, editor, data ) !== false ); 14 17 }; 15 18 -
_source/core/editor.js
559 559 */ 560 560 insertHtml : function( data ) 561 561 { 562 if ( CKEDITOR.env.ie ) 563 this.focus(); 564 562 565 this.fire( 'insertHtml', data ); 563 566 }, 564 567 … … 573 576 */ 574 577 insertElement : function( element ) 575 578 { 579 if ( CKEDITOR.env.ie ) 580 this.focus(); 581 576 582 this.fire( 'insertElement', element ); 577 583 }, 578 584