* Fixed bug #8043: Highlighting text from right to left in htmlArea RTE is erratic...
authorStanislas Rolland <typo3@sjbr.ca>
Sun, 6 Apr 2008 23:51:49 +0000 (23:51 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Sun, 6 Apr 2008 23:51:49 +0000 (23:51 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3540 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js

index 6f9102e..5d83c5e 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2008-04-06  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #7992: rtehtmlarea does not work with Firefox 3 Beta 5
+       * Fixed bug #8043: Highlighting text from right to left in htmlArea RTE is erratic in Firefox
 
 2008-04-06  Benjamin Mack  <benni@typo3.org>
 
index 47442cf..d083e19 100644 (file)
@@ -1,6 +1,7 @@
 2008-04-06  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #7992: rtehtmlarea does not work with Firefox 3 Beta 5
+       * Fixed bug #8043: Highlighting text from right to left in htmlArea RTE is erratic in Firefox
 
 2008-04-04  Stanislas Rolland  <typo3@sjbr.ca>
 
index 71e30b3..fa5b089 100644 (file)
@@ -1540,7 +1540,7 @@ HTMLArea.undoTakeSnapshot = function(editorNumber) {
  */
 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();
@@ -1551,34 +1551,14 @@ HTMLArea.prototype._undoTakeSnapshot = function () {
                ++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();
@@ -1588,14 +1568,42 @@ HTMLArea.prototype._undoTakeSnapshot = function () {
                }
        } 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