Ticket #1990: 1990_2.patch
File 1990_2.patch, 20.5 KB (added by , 16 years ago) |
---|
-
_whatsnew.html
115 115 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1792">#1792</a>] In IE, 116 116 the browser was able to enter in an infinite loop when working with multiple editors 117 117 in the same page. </li> 118 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1990">#1990</a>] In IE, 119 dialogs using API calls which deals with the selection, like InsertHtml now can 120 be sure the selection will be placed in the correct position.</li> 118 121 </ul> 119 122 <h3> 120 123 Version 2.6 Beta 1</h3> -
editor/_source/commandclasses/fcklistcommands.js
145 145 if ( rangeQueue == null ) 146 146 { 147 147 rangeQueue = [] ; 148 var selectionObject = FCK .EditorWindow.getSelection() ;148 var selectionObject = FCKSelection.GetSelection() ; 149 149 if ( selectionObject && listGroups.length == 0 ) 150 150 rangeQueue.push( selectionObject.getRangeAt( 0 ) ) ; 151 151 for ( var i = 1 ; selectionObject && i < selectionObject.rangeCount ; i++ ) -
editor/_source/internals/fck.js
660 660 661 661 var elementName = element.nodeName.toLowerCase() ; 662 662 663 FCKSelection.Restore() ; 664 663 665 // Create a range for the selection. V3 will have a new selection 664 666 // object that may internally supply this feature. 665 667 var range = new FCKDomRange( this.EditorWindow ) ; … … 863 865 { 864 866 // Prevent the caret from going between the body and the padding node in Firefox. 865 867 // i.e. <body>|<p></p></body> 866 var sel = FCK .EditorWindow.getSelection() ;868 var sel = FCKSelection.GetSelection() ; 867 869 if ( sel && sel.rangeCount == 1 ) 868 870 { 869 871 var range = sel.getRangeAt( 0 ) ; -
editor/_source/internals/fck_gecko.js
88 88 89 89 var moveCursor = function() 90 90 { 91 var selection = FCK .EditorWindow.getSelection() ;91 var selection = FCKSelection.GetSelection() ; 92 92 var range = selection.getRangeAt(0) ; 93 93 if ( ! range || ! range.collapsed ) 94 94 return ; … … 448 448 FCK._ExecCheckEmptyBlock = function() 449 449 { 450 450 FCK._FillEmptyBlock( FCK.EditorDocument.body.firstChild ) ; 451 var sel = FCK .EditorWindow.getSelection() ;451 var sel = FCKSelection.GetSelection() ; 452 452 if ( !sel || sel.rangeCount < 1 ) 453 453 return ; 454 454 var range = sel.getRangeAt( 0 ); -
editor/_source/internals/fck_ie.js
93 93 function Doc_OnSelectionChange() 94 94 { 95 95 // Don't fire the event if no document is loaded. 96 if ( FCK.EditorDocument )96 if ( !FCK.IsSelectionChangeLocked && FCK.EditorDocument ) 97 97 FCK.Events.FireEvent( "OnSelectionChange" ) ; 98 98 } 99 99 … … 155 155 FCKUndo.SaveUndoStep() ; 156 156 157 157 // Gets the actual selection. 158 var oSel = FCK .EditorDocument.selection;158 var oSel = FCKSelection.GetSelection() ; 159 159 160 160 // Deletes the actual selection contents. 161 161 if ( oSel.type.toLowerCase() == 'control' ) -
editor/_source/internals/fckdialog.js
76 76 } 77 77 78 78 return { 79 SelectionData : null,80 81 79 /** 82 80 * Opens a dialog window using the standard dialog template. 83 81 */ … … 93 91 Page : dialogPage, 94 92 Editor : window, 95 93 CustomValue : customValue, // Optional 96 SelectionData : null,97 94 TopWindow : topWindow 98 95 } 99 96 100 var currentInstance = FCK.ToolbarSet.CurrentInstance;97 FCK.ToolbarSet.CurrentInstance.Selection.Save() ; 101 98 102 // IE doens't support multiple selections, even if in different103 // IFRAMEs, like the dialog, so the current selection must be saved to104 // be restored in the dialog code.105 if ( FCKBrowserInfo.IsIE && !topDialog )106 {107 // Ensures the editor has the selection focus. (#1801)108 currentInstance.Focus() ;109 110 var editorDocument = ( currentInstance.EditMode == FCK_EDITMODE_WYSIWYG ?111 currentInstance.EditorDocument :112 FCKTools.GetElementDocument( currentInstance.EditingArea.Textarea ) ) ;113 var selection = editorDocument.selection ;114 var range ;115 116 if ( selection )117 {118 range = selection.createRange() ;119 120 // Ensure that the range comes from the editor document.121 if ( range )122 {123 if ( range.parentElement && FCKTools.GetElementDocument( range.parentElement() ) != editorDocument )124 range = null ;125 else if ( range.item && FCKTools.GetElementDocument( range.item(0) )!= editorDocument )126 range = null ;127 }128 }129 130 this.SelectionData = range ;131 }132 133 99 // Calculate the dialog position, centering it on the screen. 134 100 var viewSize = FCKTools.GetViewPaneSize( topWindow ) ; 135 101 var scrollPosition = FCKTools.GetScrollPosition( topWindow ) ; … … 183 149 else // First Dialog. 184 150 { 185 151 // Set the Focus in the browser, so the "OnBlur" event is not 186 // fired. In IE, there is no need to d othat because the dialog152 // fired. In IE, there is no need to do that because the dialog 187 153 // already moved the selection to the editing area before 188 154 // closing (EnsureSelection). Also, the Focus() call here 189 155 // causes memory leak on IE7 (weird). … … 193 159 this.HideMainCover() ; 194 160 // Bug #1918: Assigning topDialog = null directly causes IE6 to crash. 195 161 setTimeout( function(){ topDialog = null ; }, 0 ) ; 196 this.SelectionData = null ; 162 163 // Release the previously saved selection. 164 FCK.ToolbarSet.CurrentInstance.Selection.Release() ; 197 165 } 198 166 }, 199 167 -
editor/_source/internals/fckselection_gecko.js
30 30 // Check if the actual selection is a Control (IMG, TABLE, HR, etc...). 31 31 32 32 var sel ; 33 try { sel = FCK.EditorWindow.getSelection() ; } catch (e) {}33 try { sel = this.GetSelection() ; } catch (e) {} 34 34 35 35 if ( sel && sel.rangeCount == 1 ) 36 36 { … … 51 51 // element (object like and image or a table) is selected. 52 52 FCKSelection.GetSelectedElement = function() 53 53 { 54 var selection = !!FCK.EditorWindow && FCK.EditorWindow.getSelection() ;54 var selection = !!FCK.EditorWindow && this.GetSelection() ; 55 55 if ( !selection || selection.rangeCount < 1 ) 56 56 return null ; 57 57 … … 72 72 return FCKSelection.GetSelectedElement().parentNode ; 73 73 else 74 74 { 75 var oSel = FCK.EditorWindow.getSelection() ;75 var oSel = this.GetSelection() ; 76 76 if ( oSel ) 77 77 { 78 78 // make the common case fast - for collapsed/nearly collapsed selections just return anchor.parent. … … 117 117 return FCKSelection.GetSelectedElement().parentNode ; 118 118 else 119 119 { 120 var oSel = FCK.EditorWindow.getSelection() ;120 var oSel = this.GetSelection() ; 121 121 if ( oSel && oSel.rangeCount > 0 ) 122 122 { 123 123 var range = oSel.getRangeAt( startBoundary ? 0 : ( oSel.rangeCount - 1 ) ) ; … … 135 135 var oRange = FCK.EditorDocument.createRange() ; 136 136 oRange.selectNode( element ) ; 137 137 138 var oSel = FCK.EditorWindow.getSelection() ;138 var oSel = this.GetSelection() ; 139 139 oSel.removeAllRanges() ; 140 140 oSel.addRange( oRange ) ; 141 141 } 142 142 143 143 FCKSelection.Collapse = function( toStart ) 144 144 { 145 var oSel = FCK.EditorWindow.getSelection() ;145 var oSel = this.GetSelection() ; 146 146 147 147 if ( toStart == null || toStart === true ) 148 148 oSel.collapseToStart() ; … … 156 156 var oContainer = this.GetSelectedElement() ; 157 157 if ( ! oContainer && FCK.EditorWindow ) 158 158 { 159 try { oContainer = FCK.EditorWindow.getSelection().getRangeAt(0).startContainer ; }159 try { oContainer = this.GetSelection().getRangeAt(0).startContainer ; } 160 160 catch(e){} 161 161 } 162 162 … … 176 176 177 177 var oContainer = this.GetSelectedElement() ; 178 178 if ( ! oContainer ) 179 oContainer = FCK.EditorWindow.getSelection().getRangeAt(0).startContainer ;179 oContainer = this.GetSelection().getRangeAt(0).startContainer ; 180 180 181 181 while ( oContainer ) 182 182 { … … 191 191 FCKSelection.Delete = function() 192 192 { 193 193 // Gets the actual selection. 194 var oSel = FCK.EditorWindow.getSelection() ;194 var oSel = this.GetSelection() ; 195 195 196 196 // Deletes the actual selection contents. 197 197 for ( var i = 0 ; i < oSel.rangeCount ; i++ ) … … 201 201 202 202 return oSel ; 203 203 } 204 205 /** 206 * Returns the native selection object. 207 */ 208 FCKSelection.GetSelection = function() 209 { 210 return FCK.EditorWindow.getSelection() ; 211 } 212 213 // The following are IE only features (we don't need then in other browsers 214 // currently). 215 FCKSelection.Save = function() 216 {} 217 FCKSelection.Restore = function() 218 {} 219 FCKSelection.Release = function() 220 {} -
editor/_source/internals/fckselection_ie.js
28 28 // So we'd better check the object returned by createRange() rather than by looking at the type. 29 29 try 30 30 { 31 var ieType = FCK .EditorDocument.selection.type ;31 var ieType = FCKSelection.GetSelection().type ; 32 32 if ( ieType == 'Control' || ieType == 'Text' ) 33 33 return ieType ; 34 34 35 if ( FCK.EditorDocument.selection.createRange().parentElement )35 if ( this.GetSelection().createRange().parentElement ) 36 36 return 'Text' ; 37 37 } 38 38 catch(e) … … 49 49 { 50 50 if ( this.GetType() == 'Control' ) 51 51 { 52 var oRange = FCK.EditorDocument.selection.createRange() ;52 var oRange = this.GetSelection().createRange() ; 53 53 54 54 if ( oRange && oRange.item ) 55 return FCK.EditorDocument.selection.createRange().item(0) ;55 return this.GetSelection().createRange().item(0) ; 56 56 } 57 57 return null ; 58 58 } ; … … 69 69 return null ; 70 70 71 71 default : 72 return FCK.EditorDocument.selection.createRange().parentElement() ;72 return this.GetSelection().createRange().parentElement() ; 73 73 } 74 74 } ; 75 75 … … 101 101 FCKSelection.SelectNode = function( node ) 102 102 { 103 103 FCK.Focus() ; 104 FCK.EditorDocument.selection.empty() ;104 this.GetSelection().empty() ; 105 105 var oRange ; 106 106 try 107 107 { … … 124 124 FCK.Focus() ; 125 125 if ( this.GetType() == 'Text' ) 126 126 { 127 var oRange = FCK.EditorDocument.selection.createRange() ;127 var oRange = this.GetSelection().createRange() ; 128 128 oRange.collapse( toStart == null || toStart === true ) ; 129 129 oRange.select() ; 130 130 } … … 135 135 { 136 136 var oContainer ; 137 137 138 if ( FCK.EditorDocument.selection.type == "Control" )138 if ( this.GetSelection().type == "Control" ) 139 139 { 140 140 oContainer = this.GetSelectedElement() ; 141 141 } 142 142 else 143 143 { 144 var oRange = FCK.EditorDocument.selection.createRange() ;144 var oRange = this.GetSelection().createRange() ; 145 145 oContainer = oRange.parentElement() ; 146 146 } 147 147 … … 162 162 if ( ! FCK.EditorDocument ) 163 163 return null ; 164 164 165 if ( FCK.EditorDocument.selection.type == "Control" )165 if ( this.GetSelection().type == "Control" ) 166 166 { 167 oRange = FCK.EditorDocument.selection.createRange() ;167 oRange = this.GetSelection().createRange() ; 168 168 for ( i = 0 ; i < oRange.length ; i++ ) 169 169 { 170 170 if (oRange(i).parentNode) … … 176 176 } 177 177 else 178 178 { 179 oRange = FCK.EditorDocument.selection.createRange() ;179 oRange = this.GetSelection().createRange() ; 180 180 oNode = oRange.parentElement() ; 181 181 } 182 182 … … 189 189 FCKSelection.Delete = function() 190 190 { 191 191 // Gets the actual selection. 192 var oSel = FCK.EditorDocument.selection;192 var oSel = this.GetSelection() ; 193 193 194 194 // Deletes the actual selection contents. 195 195 if ( oSel.type.toLowerCase() != "none" ) … … 199 199 200 200 return oSel ; 201 201 } ; 202 203 /** 204 * Returns the native selection object. 205 */ 206 FCKSelection.GetSelection = function() 207 { 208 this.Restore() ; 209 return FCK.EditorDocument.selection ; 210 } 211 212 FCKSelection.Save = function() 213 { 214 // Ensures the editor has the selection focus. (#1801) 215 FCK.Focus() ; 216 217 var editorDocument = FCK.EditorDocument ; 218 219 if ( !editorDocument ) 220 return ; 221 222 var selection = editorDocument.selection ; 223 var range ; 224 225 if ( selection ) 226 { 227 range = selection.createRange() ; 228 229 // Ensure that the range comes from the editor document. 230 if ( range ) 231 { 232 if ( range.parentElement && FCKTools.GetElementDocument( range.parentElement() ) != editorDocument ) 233 range = null ; 234 else if ( range.item && FCKTools.GetElementDocument( range.item(0) )!= editorDocument ) 235 range = null ; 236 } 237 } 238 239 this.SelectionData = range ; 240 } 241 242 FCKSelection.Restore = function() 243 { 244 if ( this.SelectionData ) 245 { 246 FCK.IsSelectionChangeLocked = true ; 247 248 try 249 { 250 this.SelectionData.select() ; 251 } 252 catch ( e ) {} 253 254 FCK.IsSelectionChangeLocked = false ; 255 } 256 } 257 258 FCKSelection.Release = function() 259 { 260 delete this.SelectionData ; 261 } -
editor/_source/internals/fcktablehandler_gecko.js
25 25 { 26 26 var aCells = new Array() ; 27 27 28 var oSelection = FCK .EditorWindow.getSelection() ;28 var oSelection = FCKSelection.GetSelection() ; 29 29 30 30 // If the selection is a text. 31 31 if ( oSelection.rangeCount == 1 && oSelection.anchorNode.nodeType == 3 ) -
editor/_source/internals/fcktablehandler_ie.js
31 31 32 32 var aCells = new Array() ; 33 33 34 var oRange = FCK .EditorDocument.selection.createRange() ;34 var oRange = FCKSelection.GetSelection().createRange() ; 35 35 // var oParent = oRange.parentElement() ; 36 36 var oParent = FCKSelection.GetParentElement() ; 37 37 -
editor/_source/internals/fckundo.js
31 31 32 32 FCKUndo._GetBookmark = function() 33 33 { 34 FCKSelection.Restore() ; 35 34 36 var range = new FCKDomRange( FCK.EditorWindow ) ; 35 37 try 36 38 { -
editor/dialog/common/fck_dialog_common.js
280 280 oldNode.parentNode.removeChild( oldNode ) ; 281 281 oldNode = null ; 282 282 283 if ( oEditor.FCK Dialog.SelectionData )283 if ( oEditor.FCK.Selection.SelectionData ) 284 284 { 285 // Trick to refresh the selection object and avoid error in fckdialog.html Selection.EnsureSelection 285 // Trick to refresh the selection object and avoid error in 286 // fckdialog.html Selection.EnsureSelection 286 287 var oSel = oEditor.FCK.EditorDocument.selection ; 287 oEditor.FCK Dialog.SelectionData = oSel.createRange() ; // Now oSel.type will be 'None' reflecting the real situation288 oEditor.FCK.Selection.SelectionData = oSel.createRange() ; // Now oSel.type will be 'None' reflecting the real situation 288 289 } 289 290 } 290 291 oNewNode = oEditor.FCK.InsertElement( oNewNode ) ; 291 292 292 // FCK Dialog.SelectionData is broken by now since we've deleted the previously selected element.293 // So we need to reassign it.294 if ( oEditor.FCK Dialog.SelectionData )293 // FCK.Selection.SelectionData is broken by now since we've 294 // deleted the previously selected element. So we need to reassign it. 295 if ( oEditor.FCK.Selection.SelectionData ) 295 296 { 296 297 var range = oEditor.FCK.EditorDocument.body.createControlRange() ; 297 298 range.add( oNewNode ) ; 298 oEditor.FCK Dialog.SelectionData = range ;299 oEditor.FCK.Selection.SelectionData = range ; 299 300 } 300 301 } 301 302 else -
editor/dialog/fck_image/fck_image.js
250 250 oLink.href = sLnkUrl ; 251 251 else // Creating a new link. 252 252 { 253 dialog.Selection.EnsureSelection() ;254 255 253 if ( !bHasImage ) 256 254 oEditor.FCKSelection.SelectNode( oImage ) ; 257 255 -
editor/dialog/fck_link/fck_link.js
638 638 } 639 639 640 640 // Select the (first) link. 641 dialog.Selection.EnsureSelection() ;642 641 oEditor.FCKSelection.SelectNode( aLinks[0] ); 643 642 644 643 return true ; -
editor/dialog/fck_smiley.html
49 49 50 50 function InsertSmiley( url ) 51 51 { 52 dialog.Selection.EnsureSelection() ;53 54 52 oEditor.FCKUndo.SaveUndoStep() ; 55 53 56 54 var oImg = oEditor.FCK.InsertElement( 'img' ) ; -
editor/dialog/fck_specialchar.html
43 43 function insertChar(charValue) 44 44 { 45 45 oEditor.FCKUndo.SaveUndoStep() ; 46 parent.Selection.EnsureSelection() ;47 46 oEditor.FCK.InsertHtml( charValue || "" ) ; 48 47 window.parent.Cancel() ; 49 48 } -
editor/dialog/fck_tablecell.html
36 36 var oDOM = oEditor.FCK.EditorDocument ; 37 37 38 38 // Array of selected Cells 39 dialog.Selection.EnsureSelection() ;40 39 var aCells = oEditor.FCKTableHandler.GetSelectedCells() ; 41 40 42 41 window.onload = function() -
editor/fckdialog.html
375 375 }() ; 376 376 377 377 // Selection related functions. 378 var Selection = function() 378 //(Became simple shortcuts after the fix for #1990) 379 var Selection = 379 380 { 380 return { 381 /** 382 * Ensures that the editing area contains an active selection. This is a 383 * requirement for IE, as it looses the selection when the focus moves to other 384 * frames. 385 */ 386 EnsureSelection : function() 387 { 388 if ( FCKDialog.SelectionData ) 389 { 390 try 391 { 392 FCKDialog.SelectionData.select() ; 393 } 394 catch ( e ) {} 395 } 396 }, 381 /** 382 * Ensures that the editing area contains an active selection. This is a 383 * requirement for IE, as it looses the selection when the focus moves to other 384 * frames. 385 */ 386 EnsureSelection : function() 387 { 388 FCK.Selection.Restore() ; 389 }, 397 390 398 /** 399 * Get the FCKSelection object for the editor instance. 400 */ 401 GetSelection : function() 402 { 403 this.EnsureSelection() ; 404 return FCK.Selection ; 405 }, 391 /** 392 * Get the FCKSelection object for the editor instance. 393 */ 394 GetSelection : function() 395 { 396 return FCK.Selection ; 397 }, 406 398 407 /** 408 * Get the selected element in the editing area (for object selections). 409 */ 410 GetSelectedElement : function() 411 { 412 return this.GetSelection().GetSelectedElement() ; 413 } 414 } ; 415 }() ; 399 /** 400 * Get the selected element in the editing area (for object selections). 401 */ 402 GetSelectedElement : function() 403 { 404 return FCK.Selection.GetSelectedElement() ; 405 } 406 } 416 407 417 408 // Tab related functions. 418 409 var Tabs = function()