Changeset 636
- Timestamp:
- 2007-08-08 05:58:43 (17 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/_source/internals/fckundo.js
r634 r636 78 78 } 79 79 80 FCKUndo._CompareCursors = function( cursor1, cursor2 ) 81 { 82 for ( var i = 0 ; i < Math.min( cursor1.length, cursor2.length ) ; i++ ) 83 { 84 if ( cursor1[i] < cursor2[i] ) 85 return -1; 86 else if (cursor1[i] > cursor2[i] ) 87 return 1; 88 } 89 if ( cursor1.length < cursor2.length ) 90 return -1; 91 else if (cursor1.length > cursor2.length ) 92 return 1; 93 return 0; 94 } 95 96 FCKUndo._CheckIsBookmarksEqual = function( bookmark1, bookmark2 ) 97 { 98 if ( FCKBrowserInfo.IsIE ) 99 { 100 var startOffset1 = bookmark1[1].search( bookmark1[0].StartId ) ; 101 var startOffset2 = bookmark2[1].search( bookmark2[0].StartId ) ; 102 var endOffset1 = bookmark1[1].search( bookmark1[0].EndId ) ; 103 var endOffset2 = bookmark2[1].search( bookmark2[0].EndId ) ; 104 return startOffset1 == startOffset2 && endOffset1 == endOffset2 ; 105 } 106 else 107 { 108 return this._CompareCursors( bookmark1.Start, bookmark2.Start ) == 0 109 && this._CompareCursors( bookmark1.End, bookmark2.End ) == 0 ; 110 } 111 } 112 80 113 FCKUndo.SaveUndoStep = function() 81 114 { … … 90 123 // Get the HTML content. 91 124 var sHtml = FCK.EditorDocument.body.innerHTML ; 125 var bookmark = this._GetBookmark() ; 92 126 93 127 // Shrink the array to the current level. … … 95 129 96 130 // Cancel operation if the new step is identical to the previous one. 97 if ( this.CurrentIndex > 0 && sHtml == this.SavedData[ this.CurrentIndex ][0] ) 131 if ( this.CurrentIndex > 0 132 && sHtml == this.SavedData[ this.CurrentIndex ][0] 133 && this._CheckIsBookmarksEqual( bookmark, this.SavedData[ this.CurrentIndex ][1] ) ) 98 134 return ; 99 135 // Save the selection and caret position in the first undo level for the first change. 100 136 else if ( this.CurrentIndex == 0 && this.SavedData.length && sHtml == this.SavedData[0][0] ) 101 137 { 102 this.SavedData[0][1] = this._GetBookmark();138 this.SavedData[0][1] = bookmark ; 103 139 return ; 104 140 } … … 112 148 113 149 // Save the new level in front of the actual position. 114 this.SavedData[ this.CurrentIndex ] = [ sHtml, this._GetBookmark()] ;150 this.SavedData[ this.CurrentIndex ] = [ sHtml, bookmark ] ; 115 151 116 152 FCK.Events.FireEvent( "OnSelectionChange" ) ;