Changeset 393
- Timestamp:
- 2007-06-27 08:55:55 (19 months ago)
- Location:
- FCKeditor/trunk/editor/_source
- Files:
-
- 3 modified
-
commandclasses/fck_othercommands.js (modified) (2 diffs)
-
internals/fck_gecko.js (modified) (2 diffs)
-
internals/fckundo_gecko.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/_source/commandclasses/fck_othercommands.js
r347 r393 231 231 FCKUndoCommand.prototype.Execute = function() 232 232 { 233 if ( FCKBrowserInfo.IsIE ) 234 FCKUndo.Undo() ; 235 else 236 FCK.ExecuteNamedCommand( 'Undo' ) ; 233 FCKUndo.Undo() ; 237 234 } 238 235 239 236 FCKUndoCommand.prototype.GetState = function() 240 237 { 241 if ( FCKBrowserInfo.IsIE ) 242 return ( FCKUndo.CheckUndoState() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ; 243 else 244 return FCK.GetNamedCommandState( 'Undo' ) ; 238 return ( FCKUndo.CheckUndoState() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ; 245 239 } 246 240 … … 253 247 FCKRedoCommand.prototype.Execute = function() 254 248 { 255 if ( FCKBrowserInfo.IsIE ) 256 FCKUndo.Redo() ; 257 else 258 FCK.ExecuteNamedCommand( 'Redo' ) ; 249 FCKUndo.Redo() ; 259 250 } 260 251 261 252 FCKRedoCommand.prototype.GetState = function() 262 253 { 263 if ( FCKBrowserInfo.IsIE ) 264 return ( FCKUndo.CheckRedoState() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ; 265 else 266 return FCK.GetNamedCommandState( 'Redo' ) ; 254 return ( FCKUndo.CheckRedoState() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ; 267 255 } 268 256 -
FCKeditor/trunk/editor/_source/internals/fck_gecko.js
r341 r393 26 26 FCK.Description = "FCKeditor for Gecko Browsers" ; 27 27 28 FCK._KeyDownUndo = function() 29 { 30 if ( !FCKUndo.Typing ) 31 { 32 FCKUndo.SaveUndoStep() ; 33 FCKUndo.Typing = true ; 34 FCK.Events.FireEvent( "OnSelectionChange" ) ; 35 } 36 37 FCKUndo.TypesCount++ ; 38 39 if ( FCKUndo.TypesCount > FCKUndo.MaxTypes ) 40 { 41 FCKUndo.TypesCount = 0 ; 42 FCKUndo.SaveUndoStep() ; 43 } 44 } 45 46 FCK._KeyDownListener = function( evt ) 47 { 48 if ( FCK.EditorWindow ) 49 { 50 if ( !( evt.keyCode >= 16 && evt.keyCode <= 18 ) ) 51 FCK._KeyDownUndo(); 52 } 53 return true; 54 } 55 28 56 FCK.InitializeBehaviors = function() 29 57 { … … 59 87 } 60 88 this.EditorDocument.addEventListener( 'dblclick', this._DblClickListener, true ) ; 89 90 // Record changes for the undo system when there are key down events. 91 this.EditorDocument.addEventListener( 'keydown', this._KeyDownListener, false ) ; 61 92 62 93 // Reset the context menu. -
FCKeditor/trunk/editor/_source/internals/fckundo_gecko.js
r132 r393 24 24 var FCKUndo = new Object() ; 25 25 26 FCKUndo.SavedData = new Array() ; 27 FCKUndo.CurrentIndex = -1 ; 28 FCKUndo.TypesCount = FCKUndo.MaxTypes = 25 ; 29 FCKUndo.Typing = false; 30 26 31 FCKUndo.SaveUndoStep = function() 27 {} 32 { 33 if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) 34 return ; 35 36 // Shrink the array to the current level. 37 FCKUndo.SavedData = FCKUndo.SavedData.slice( 0, FCKUndo.CurrentIndex + 1 ) ; 38 39 // Get the Actual HTML. 40 var sHtml = FCK.EditorDocument.body.innerHTML ; 41 42 // Cancel operation if the new step is identical to the previous one. 43 if ( FCKUndo.CurrentIndex >= 0 && sHtml == FCKUndo.SavedData[ FCKUndo.CurrentIndex ][0] ) 44 return ; 45 46 // If we reach the Maximun number of undo levels, we must remove the first 47 // entry of the list shifting all elements. 48 if ( FCKUndo.CurrentIndex + 1 >= FCKConfig.MaxUndoLevels ) 49 FCKUndo.SavedData.shift() ; 50 else 51 FCKUndo.CurrentIndex++ ; 52 53 // Get the actual selection. 54 // TODO: How to handle this in Gecko? 55 56 // Save the new level in front of the actual position. 57 FCKUndo.SavedData[ FCKUndo.CurrentIndex ] = [ sHtml, null ] ; 58 59 FCK.Events.FireEvent( "OnSelectionChange" ) ; 60 } 61 62 FCKUndo.CheckUndoState = function() 63 { 64 return ( FCKUndo.Typing || FCKUndo.CurrentIndex > 0 ) ; 65 } 66 67 FCKUndo.CheckRedoState = function() 68 { 69 return ( !FCKUndo.Typing && FCKUndo.CurrentIndex < ( FCKUndo.SavedData.length - 1 ) ) ; 70 } 71 72 FCKUndo.Undo = function() 73 { 74 if ( FCKUndo.CheckUndoState() ) 75 { 76 // If it is the first step. 77 if ( FCKUndo.CurrentIndex == ( FCKUndo.SavedData.length - 1 ) ) 78 { 79 // Save the actual state for a possible "Redo" call. 80 FCKUndo.SaveUndoStep() ; 81 } 82 83 // Go a step back. 84 FCKUndo._ApplyUndoLevel( --FCKUndo.CurrentIndex ) ; 85 86 FCK.Events.FireEvent( "OnSelectionChange" ) ; 87 } 88 } 89 90 FCKUndo.Redo = function() 91 { 92 if ( FCKUndo.CheckRedoState() ) 93 { 94 // Go a step forward. 95 FCKUndo._ApplyUndoLevel( ++FCKUndo.CurrentIndex ) ; 96 97 FCK.Events.FireEvent( "OnSelectionChange" ) ; 98 } 99 } 100 101 FCKUndo._ApplyUndoLevel = function(level) 102 { 103 var oData = FCKUndo.SavedData[ level ] ; 104 105 if ( !oData ) 106 return ; 107 108 // Update the editor contents with that step data. 109 FCK.EditorDocument.body.innerHTML = oData[0] ; 110 111 // TODO: Restore selection in Gecko 112 113 FCKUndo.TypesCount = 0 ; 114 FCKUndo.Typing = false ; 115 }