* Fixed bug #4121: Pasting content on RTE moves cursor to the top of the text
authorStanislas Rolland <typo3@sjbr.ca>
Sat, 1 Mar 2008 02:52:05 +0000 (02:52 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Sat, 1 Mar 2008 02:52:05 +0000 (02:52 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3328 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/doc/manual.sxw
typo3/sysext/rtehtmlarea/extensions/TYPO3HtmlParser/class.tx_rtehtmlarea_typo3htmlparser.php
typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3HtmlParser/typo3html-parser.js

index c620378..5b9aa07 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-29  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #4121: Pasting content on RTE moves cursor to the top of the text
+
 2008-02-29  Michael Stucki  <michael@typo3.org>
 
        * Fixed bug #7545: Explain queries does not work when selecting multiple tables (patch by Ingo Schmitt)
@@ -13,7 +17,7 @@
 2008-02-28  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
        * Fixed bug #7684: htmlArea RTE: Cursor positioning when creating new table
-       * Partially fixed bug #7614: htmlArea RTE: Poor tag handling everywhere in Opera
+       * Partially fixed bug #6714: htmlArea RTE: Poor tag handling everywhere in Opera
 
 2008-02-28  Ingmar Schlecht  <ingmar@typo3.org>
 
index dab4dab..753035d 100644 (file)
@@ -1,7 +1,11 @@
+2008-02-29  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #4121: Pasting content on RTE moves cursor to the top of the text
+       
 2008-02-28  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
        * Fixed bug #7684: htmlArea RTE: Cursor positioning when creating new table
-       * Partially fixed bug #7614: htmlArea RTE: Poor tag handling everywhere in Opera
+       * Partially fixed bug #6714: htmlArea RTE: Poor tag handling everywhere in Opera
 
 2008-02-27  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
index e246e59..b2001b7 100644 (file)
Binary files a/typo3/sysext/rtehtmlarea/doc/manual.sxw and b/typo3/sysext/rtehtmlarea/doc/manual.sxw differ
index f55d0b6..3dd9664 100644 (file)
@@ -49,7 +49,7 @@ class tx_rtehtmlarea_typo3htmlparser extends tx_rtehtmlareaapi {
                );
        
        public function main($parentObject) {
-               return parent::main($parentObject) && $this->thisConfig['enableWordClean'] && is_array($this->thisConfig['enableWordClean.']);
+               return parent::main($parentObject) && $this->thisConfig['enableWordClean'] && is_array($this->thisConfig['enableWordClean.']['HTMLparser.']);
        }
        
        /**
index c0514a4..f07e9a2 100644 (file)
@@ -366,9 +366,9 @@ HTMLArea.prototype.getBookmark = function (range) {
  */
 HTMLArea.prototype.getBookmarkNode = function(bookmark, endPoint) {
        if (endPoint) {
-               return bookmark.startNode || this._doc.getElementById(bookmark.startId);
+               return this._doc.getElementById(bookmark.startId);
        } else {
-               return bookmark.endNode || this._doc.getElementById(bookmark.endId);
+               return this._doc.getElementById(bookmark.endId);
        }
 };
 
@@ -518,8 +518,10 @@ HTMLArea.prototype._mozillaPasteException = function(cmdID, UI, param) {
                // Mozilla lauches an exception, but can paste anyway on ctrl-V
                // UI is false on keyboard shortcut, and undefined on button click
        if(typeof(UI) != "undefined") {
-               this._doc.execCommand(cmdID, UI, param);
-               if (cmdID == "Paste" && this.config.killWordOnPaste) HTMLArea._wordClean(this._doc.body);
+               try { this._doc.execCommand(cmdID, UI, param); } catch(e) { }
+               if (cmdID == "Paste" && this._toolbarObjects.CleanWord) {
+                       this._toolbarObjects.CleanWord.cmd(this, "CleanWord");
+               }
        } else if (this.config.enableMozillaExtension) {
                if (confirm(HTMLArea.I18N.msg["Allow-Clipboard-Helper-Extension"])) {
                        if (InstallTrigger.enabled()) {
index 5306ccc..75dbad7 100644 (file)
@@ -1813,7 +1813,8 @@ HTMLArea.prototype.execCommand = function(cmdID, UI, param) {
                case "Paste"    :
                        try {
                                this._doc.execCommand(cmdID, false, null);
-                               if (cmdID == "Paste" && this._toolbarObjects.CleanWord) {
+                                       // In FF3, the paste operation will indeed trigger the paste event
+                               if (HTMLArea.is_gecko && cmdID == "Paste" && this._toolbarObjects.CleanWord && navigator.productSub < 2008020514) {
                                        this._toolbarObjects.CleanWord.cmd(this, "CleanWord");
                                }
                        } catch (e) {
@@ -1890,10 +1891,13 @@ HTMLArea._editorEvent = function(ev) {
                                                        editor.execCommand(cmd, false, null);
                                                        HTMLArea._stopEvent(ev);
                                                        return false;
-                                               } else if (editor._toolbarObjects.CleanWord) {
-                                                       var cleanLaterFunctRef = editor.plugins.DefaultClean ? editor.plugins.DefaultClean.instance.cleanLaterFunctRef : (editor.plugins.TYPO3HtmlParser ? editor.plugins.TYPO3HtmlParser.instance.cleanLaterFunctRef : null);
-                                                       if (cleanLaterFunctRef) {
-                                                               window.setTimeout(cleanLaterFunctRef, 50);
+                                                       // In FF3, the paste operation will indeed trigger the paste event
+                                               } else if (HTMLArea.is_opera || (HTMLArea.is_gecko && navigator.productSub < 2008020514)) {
+                                                       if (editor._toolbarObjects.CleanWord) {
+                                                               var cleanLaterFunctRef = editor.plugins.DefaultClean ? editor.plugins.DefaultClean.instance.cleanLaterFunctRef : (editor.plugins.TYPO3HtmlParser ? editor.plugins.TYPO3HtmlParser.instance.cleanLaterFunctRef : null);
+                                                               if (cleanLaterFunctRef) {
+                                                                       window.setTimeout(cleanLaterFunctRef, 50);
+                                                               }
                                                        }
                                                }
                                                break;
@@ -2029,10 +2033,11 @@ HTMLArea.prototype.getInnerHTML = function() {
 HTMLArea.prototype.setHTML = function(html) {
        switch (this._editMode) {
                case "wysiwyg":
-                       if(!this.config.fullPage) this._doc.body.innerHTML = html;
-                               else this._doc.body.innerHTML = html;
+                       this._doc.body.innerHTML = html;
+                       break;
+               case "textmode":
+                       this._textArea.value = html;
                        break;
-               case "textmode": this._textArea.value = html; break;
        }
        return false;
 };
index 35dce20..b165d04 100644 (file)
@@ -82,8 +82,8 @@ TYPO3HtmlParser = HTMLArea.Plugin.extend({
                        // Could be a button or its hotkey
                var buttonId = this.translateHotKey(id);
                buttonId = buttonId ? buttonId : id;
-               
-               this.clean(this.editor._doc.body);
+               var bookmark = this.editor.getBookmark(this.editor._createRange(this.editor._getSelection()));
+               this.clean(this.editor._doc.body, bookmark);
                return false;
        },
        
@@ -93,22 +93,24 @@ TYPO3HtmlParser = HTMLArea.Plugin.extend({
                HTMLArea._addEvents((HTMLArea.is_ie ? doc.body : doc), ["paste","dragdrop","drop"], cleanFunctRef, true);
        },
        
-       clean : function(body) {
+       clean : function(body, bookmark) {
                var editor = this.editor;
                var content = {
                        editorNo : this.editorNumber,
                        content : body.innerHTML
                };
-               this.postData(this.parseHtmlModulePath, content, function(response) { editor.setHTML(response); });
-               return true;
+               this.postData(  this.parseHtmlModulePath,
+                               content,
+                               function(response) {
+                                       editor.setHTML(response);
+                                       editor.selectRange(editor.moveToBookmark(bookmark));
+                               }
+               );
        },
        
        cleanLater : function () {
-               this.clean(this.editor._doc.body);
-               if (this.doUpdateToolbar) {
-                       this.editor.updateToolbar();
-               }
-               this.doUpdateToolbar = false;
+               var bookmark = this.editor.getBookmark(this.editor._createRange(this.editor._getSelection()));
+               this.clean(this.editor._doc.body, bookmark);
        },
        
        /*
@@ -125,7 +127,6 @@ TYPO3HtmlParser = HTMLArea.Plugin.extend({
                if (typeof(HTMLArea.Dialog) != "undefined" && HTMLArea.Dialog.TYPO3Image) {
                        HTMLArea.Dialog.TYPO3Image.close();
                } else {
-                       this.doUpdateToolbar = false;
                        window.setTimeout(this.cleanLaterFunctRef, 250);
                }
        }