Changeset 1795
- Timestamp:
- 03/25/08 11:24:02 (5 years ago)
- Location:
- FCKeditor/trunk
- Files:
-
- 18 edited
-
_whatsnew.html (modified) (1 diff)
-
editor/_source/commandclasses/fcklistcommands.js (modified) (1 diff)
-
editor/_source/internals/fck.js (modified) (2 diffs)
-
editor/_source/internals/fck_gecko.js (modified) (2 diffs)
-
editor/_source/internals/fck_ie.js (modified) (2 diffs)
-
editor/_source/internals/fckdialog.js (modified) (4 diffs)
-
editor/_source/internals/fckselection_gecko.js (modified) (10 diffs)
-
editor/_source/internals/fckselection_ie.js (modified) (11 diffs)
-
editor/_source/internals/fcktablehandler_gecko.js (modified) (1 diff)
-
editor/_source/internals/fcktablehandler_ie.js (modified) (1 diff)
-
editor/_source/internals/fckundo.js (modified) (1 diff)
-
editor/dialog/common/fck_dialog_common.js (modified) (1 diff)
-
editor/dialog/fck_image/fck_image.js (modified) (1 diff)
-
editor/dialog/fck_link/fck_link.js (modified) (1 diff)
-
editor/dialog/fck_smiley.html (modified) (1 diff)
-
editor/dialog/fck_specialchar.html (modified) (1 diff)
-
editor/dialog/fck_tablecell.html (modified) (1 diff)
-
editor/fckdialog.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/_whatsnew.html
r1793 r1795 134 134 the caret will not any more move to the previous line when selecting a Format style 135 135 inside an empty paragraph.</li> 136 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1990">#1990</a>] In IE, 137 dialogs using API calls which deals with the selection, like InsertHtml now can 138 be sure the selection will be placed in the correct position.</li> 136 139 </ul> 137 140 <h3> -
FCKeditor/trunk/editor/_source/commandclasses/fcklistcommands.js
r1565 r1795 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 ) ) ; -
FCKeditor/trunk/editor/_source/internals/fck.js
r1790 r1795 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. … … 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 { -
FCKeditor/trunk/editor/_source/internals/fck_gecko.js
r1741 r1795 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 ) … … 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 ; -
FCKeditor/trunk/editor/_source/internals/fck_ie.js
r1587 r1795 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 } … … 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. -
FCKeditor/trunk/editor/_source/internals/fckdialog.js
r1776 r1795 86 86 87 87 return { 88 SelectionData : null,89 90 88 /** 91 89 * Opens a dialog window using the standard dialog template. … … 103 101 Editor : window, 104 102 CustomValue : customValue, // Optional 105 SelectionData : null,106 103 TopWindow : topWindow 107 104 } 108 105 109 var currentInstance = FCK.ToolbarSet.CurrentInstance ; 110 111 // IE doens't support multiple selections, even if in different 112 // IFRAMEs, like the dialog, so the current selection must be saved to 113 // be restored in the dialog code. 114 if ( FCKBrowserInfo.IsIE && !topDialog ) 115 { 116 // Ensures the editor has the selection focus. (#1801) 117 currentInstance.Focus() ; 118 119 var editorDocument = ( currentInstance.EditMode == FCK_EDITMODE_WYSIWYG ? 120 currentInstance.EditorDocument : 121 FCKTools.GetElementDocument( currentInstance.EditingArea.Textarea ) ) ; 122 var selection = editorDocument.selection ; 123 var range ; 124 125 if ( selection ) 126 { 127 range = selection.createRange() ; 128 129 // Ensure that the range comes from the editor document. 130 if ( range ) 131 { 132 if ( range.parentElement && FCKTools.GetElementDocument( range.parentElement() ) != editorDocument ) 133 range = null ; 134 else if ( range.item && FCKTools.GetElementDocument( range.item(0) )!= editorDocument ) 135 range = null ; 136 } 137 } 138 139 this.SelectionData = range ; 140 } 106 FCK.ToolbarSet.CurrentInstance.Selection.Save() ; 141 107 142 108 // Calculate the dialog position, centering it on the screen. … … 194 160 { 195 161 // Set the Focus in the browser, so the "OnBlur" event is not 196 // fired. In IE, there is no need to d othat because the dialog162 // fired. In IE, there is no need to do that because the dialog 197 163 // already moved the selection to the editing area before 198 164 // closing (EnsureSelection). Also, the Focus() call here … … 204 170 // Bug #1918: Assigning topDialog = null directly causes IE6 to crash. 205 171 setTimeout( function(){ topDialog = null ; }, 0 ) ; 206 this.SelectionData = null ; 172 173 // Release the previously saved selection. 174 FCK.ToolbarSet.CurrentInstance.Selection.Release() ; 207 175 } 208 176 }, -
FCKeditor/trunk/editor/_source/internals/fckselection_gecko.js
r1565 r1795 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 ) … … 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 ; … … 73 73 else 74 74 { 75 var oSel = FCK.EditorWindow.getSelection() ;75 var oSel = this.GetSelection() ; 76 76 if ( oSel ) 77 77 { … … 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 { … … 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 ) ; … … 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 ) … … 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 } … … 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 ) … … 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. … … 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 {} -
FCKeditor/trunk/editor/_source/internals/fckselection_ie.js
r1565 r1795 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 } … … 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 ; … … 70 70 71 71 default : 72 return FCK.EditorDocument.selection.createRange().parentElement() ;72 return this.GetSelection().createRange().parentElement() ; 73 73 } 74 74 } ; … … 102 102 { 103 103 FCK.Focus() ; 104 FCK.EditorDocument.selection.empty() ;104 this.GetSelection().empty() ; 105 105 var oRange ; 106 106 try … … 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() ; … … 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() ; … … 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 } … … 163 163 return null ; 164 164 165 if ( FCK.EditorDocument.selection.type == "Control" )166 { 167 oRange = FCK.EditorDocument.selection.createRange() ;165 if ( this.GetSelection().type == "Control" ) 166 { 167 oRange = this.GetSelection().createRange() ; 168 168 for ( i = 0 ; i < oRange.length ; i++ ) 169 169 { … … 177 177 else 178 178 { 179 oRange = FCK.EditorDocument.selection.createRange() ;179 oRange = this.GetSelection().createRange() ; 180 180 oNode = oRange.parentElement() ; 181 181 } … … 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. … … 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 } -
FCKeditor/trunk/editor/_source/internals/fcktablehandler_gecko.js
r1565 r1795 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. -
FCKeditor/trunk/editor/_source/internals/fcktablehandler_ie.js
r1565 r1795 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() ; -
FCKeditor/trunk/editor/_source/internals/fckundo.js
r1565 r1795 32 32 FCKUndo._GetBookmark = function() 33 33 { 34 FCKSelection.Restore() ; 35 34 36 var range = new FCKDomRange( FCK.EditorWindow ) ; 35 37 try -
FCKeditor/trunk/editor/dialog/common/fck_dialog_common.js
r1792 r1795 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 } -
FCKeditor/trunk/editor/dialog/fck_image/fck_image.js
r1598 r1795 251 251 else // Creating a new link. 252 252 { 253 dialog.Selection.EnsureSelection() ;254 255 253 if ( !bHasImage ) 256 254 oEditor.FCKSelection.SelectNode( oImage ) ; -
FCKeditor/trunk/editor/dialog/fck_link/fck_link.js
r1774 r1795 639 639 640 640 // Select the (first) link. 641 dialog.Selection.EnsureSelection() ;642 641 oEditor.FCKSelection.SelectNode( aLinks[0] ); 643 642 -
FCKeditor/trunk/editor/dialog/fck_smiley.html
r1565 r1795 50 50 function InsertSmiley( url ) 51 51 { 52 dialog.Selection.EnsureSelection() ;53 54 52 oEditor.FCKUndo.SaveUndoStep() ; 55 53 -
FCKeditor/trunk/editor/dialog/fck_specialchar.html
r1565 r1795 44 44 { 45 45 oEditor.FCKUndo.SaveUndoStep() ; 46 parent.Selection.EnsureSelection() ;47 46 oEditor.FCK.InsertHtml( charValue || "" ) ; 48 47 window.parent.Cancel() ; -
FCKeditor/trunk/editor/dialog/fck_tablecell.html
r1565 r1795 37 37 38 38 // Array of selected Cells 39 dialog.Selection.EnsureSelection() ;40 39 var aCells = oEditor.FCKTableHandler.GetSelectedCells() ; 41 40 -
FCKeditor/trunk/editor/fckdialog.html
r1777 r1795 376 376 377 377 // Selection related functions. 378 var Selection = function() 379 { 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 }, 397 398 /** 399 * Get the FCKSelection object for the editor instance. 400 */ 401 GetSelection : function() 402 { 403 this.EnsureSelection() ; 404 return FCK.Selection ; 405 }, 406 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 }() ; 378 //(Became simple shortcuts after the fix for #1990) 379 var Selection = 380 { 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 }, 390 391 /** 392 * Get the FCKSelection object for the editor instance. 393 */ 394 GetSelection : function() 395 { 396 return FCK.Selection ; 397 }, 398 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.
Note: See TracChangeset
for help on using the changeset viewer.
