Project

General

Profile

Bug #18577 ยป rtehtmlarea_bugfix_8043.patch

Administrator Admin, 2008-04-07 01:43

View differences:

typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js (working copy)
*/
HTMLArea.prototype._undoTakeSnapshot = function () {
var currentTime = (new Date()).getTime();
var newSnapshot = false, bookmark = null, bookmarkedText = null;
var newSnapshot = false;
if (this._undoPos >= this.config.undoSteps) {
// Remove the first element
this._undoQueue.shift();
......
++this._undoPos;
newSnapshot = true;
}
// Insert a bookmark
if (this.getMode() === "wysiwyg" && this.isEditable()) {
var selection = this._getSelection();
if ((HTMLArea.is_gecko && !HTMLArea.is_opera) || (HTMLArea.is_ie && selection.type.toLowerCase() != "control")) {
try { // catch error in FF when the selection contains no usable range
bookmark = this.getBookmark(this._createRange(selection));
} catch (e) {
bookmark = null;
}
}
}
// Get the bookmarked html text and remove the bookmark
if (bookmark) {
bookmarkedText = this.getInnerHTML();
this.moveToBookmark(bookmark);
}
// Get the html text
var txt = this.getInnerHTML();
if (newSnapshot) {
// If previous slot contains the same text, a new one should not be used
if (this._undoPos == 0 || this._undoQueue[this._undoPos - 1].text != txt) {
this._undoQueue[this._undoPos] = {
text : txt,
time : currentTime,
bookmark : bookmark,
bookmarkedText : bookmarkedText
};
this._undoQueue[this._undoPos] = this.buildUndoSnapshot();
this._undoQueue[this._undoPos].time = currentTime;
this._undoQueue.length = this._undoPos + 1;
if (this._undoPos == 1) {
this.updateToolbar();
......
}
} else {
if (this._undoQueue[this._undoPos].text != txt){
this._undoQueue[this._undoPos].text = txt;
this._undoQueue[this._undoPos].bookmark = bookmark;
this._undoQueue[this._undoPos].bookmarkedText = bookmarkedText;
var snapshot = this.buildUndoSnapshot();
this._undoQueue[this._undoPos].text = snapshot.txt;
this._undoQueue[this._undoPos].bookmark = snapshot.bookmark;
this._undoQueue[this._undoPos].bookmarkedText = snapshot.bookmarkedText;
this._undoQueue.length = this._undoPos + 1;
}
}
};
HTMLArea.prototype.buildUndoSnapshot = function () {
var text, bookmark = null, bookmarkedText = null;
// Insert a bookmark
if (this.getMode() === "wysiwyg" && this.isEditable()) {
var selection = this._getSelection();
if ((HTMLArea.is_gecko && !HTMLArea.is_opera) || (HTMLArea.is_ie && selection.type.toLowerCase() != "control")) {
try { // catch error in FF when the selection contains no usable range
bookmark = this.getBookmark(this._createRange(selection));
} catch (e) {
bookmark = null;
}
}
}
// Get the bookmarked html text and remove the bookmark
if (bookmark) {
bookmarkedText = this.getInnerHTML();
this.moveToBookmark(bookmark);
}
// Get the html text
var text = this.getInnerHTML();
return {
text : text,
bookmark : bookmark,
bookmarkedText : bookmarkedText
};
};
HTMLArea.prototype.undo = function () {
if (this._undoPos > 0) {
// Make sure we would not loose any changes
    (1-1/1)