2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* IE specific implementation for the Undo/Redo system.
24
var FCKUndo = new Object() ;
26
FCKUndo.SavedData = new Array() ;
27
FCKUndo.CurrentIndex = -1 ;
28
FCKUndo.TypesCount = FCKUndo.MaxTypes = 25 ;
29
FCKUndo.Typing = false ;
31
FCKUndo.SaveUndoStep = function()
33
if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
36
// Shrink the array to the current level.
37
FCKUndo.SavedData = FCKUndo.SavedData.slice( 0, FCKUndo.CurrentIndex + 1 ) ;
39
// Get the Actual HTML.
40
var sHtml = FCK.EditorDocument.body.innerHTML ;
42
// Cancel operation if the new step is identical to the previous one.
43
if ( FCKUndo.CurrentIndex >= 0 && sHtml == FCKUndo.SavedData[ FCKUndo.CurrentIndex ][0] )
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() ;
51
FCKUndo.CurrentIndex++ ;
53
// Get the actual selection.
55
if ( FCK.EditorDocument.selection.type == 'Text' )
56
sBookmark = FCK.EditorDocument.selection.createRange().getBookmark() ;
58
// Save the new level in front of the actual position.
59
FCKUndo.SavedData[ FCKUndo.CurrentIndex ] = [ sHtml, sBookmark ] ;
61
FCK.Events.FireEvent( "OnSelectionChange" ) ;
64
FCKUndo.CheckUndoState = function()
66
return ( FCKUndo.Typing || FCKUndo.CurrentIndex > 0 ) ;
69
FCKUndo.CheckRedoState = function()
71
return ( !FCKUndo.Typing && FCKUndo.CurrentIndex < ( FCKUndo.SavedData.length - 1 ) ) ;
74
FCKUndo.Undo = function()
76
if ( FCKUndo.CheckUndoState() )
78
// If it is the first step.
79
if ( FCKUndo.CurrentIndex == ( FCKUndo.SavedData.length - 1 ) )
81
// Save the actual state for a possible "Redo" call.
82
FCKUndo.SaveUndoStep() ;
86
FCKUndo._ApplyUndoLevel( --FCKUndo.CurrentIndex ) ;
88
FCK.Events.FireEvent( "OnSelectionChange" ) ;
92
FCKUndo.Redo = function()
94
if ( FCKUndo.CheckRedoState() )
97
FCKUndo._ApplyUndoLevel( ++FCKUndo.CurrentIndex ) ;
99
FCK.Events.FireEvent( "OnSelectionChange" ) ;
103
FCKUndo._ApplyUndoLevel = function(level)
105
var oData = FCKUndo.SavedData[ level ] ;
110
// Update the editor contents with that step data.
111
FCK.SetInnerHtml( oData[0] ) ;
112
// FCK.EditorDocument.body.innerHTML = oData[0] ;
116
var oRange = FCK.EditorDocument.selection.createRange() ;
117
oRange.moveToBookmark( oData[1] ) ;
121
FCKUndo.TypesCount = 0 ;
122
FCKUndo.Typing = false ;
b'\\ No newline at end of file'