Fixed bug #11915: htmlArea RTE: superfluous span tags in content after server-based...
authorStanislas Rolland <typo3@sjbr.ca>
Tue, 15 Sep 2009 16:16:38 +0000 (16:16 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 15 Sep 2009 16:16:38 +0000 (16:16 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-2@5930 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3HtmlParser/typo3html-parser.js

index b1c72bb..ae911b8 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-09-15  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #11915: htmlArea RTE: superfluous span tags in content after server-based cleaning on paste operation
+
 2009-09-13  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #11847: htmlArea RTE displays empty editing area in Opera 10
index 5fc1667..aa232a9 100644 (file)
@@ -1,3 +1,7 @@
+2009-09-15  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #11915: htmlArea RTE: superfluous span tags in content after server-based cleaning on paste operation
+
 2009-09-13  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #11847: htmlArea RTE displays empty editing area in Opera 10
index 6041d15..2f356a6 100644 (file)
@@ -1983,8 +1983,8 @@ HTMLArea.prototype.execCommand = function(cmdID, UI, param) {
                case "Paste"    :
                        try {
                                this._doc.execCommand(cmdID, false, null);
-                                       // In FF3, the paste operation will indeed trigger the paste event
-                               if (HTMLArea.is_gecko && cmdID == "Paste" && this._toolbarObjects.CleanWord && navigator.productSub < 2008020514) {
+                                       // In FF3, the paste operation will trigger the paste event
+                               if (cmdID == "Paste" && this._toolbarObjects.CleanWord && (HTMLArea.is_opera || (HTMLArea.is_gecko && navigator.productSub < 20080514))) {
                                        this._toolbarObjects.CleanWord.cmd(this, "CleanWord");
                                }
                        } catch (e) {
@@ -2055,7 +2055,7 @@ HTMLArea._editorEvent = function(ev) {
                                                return false;
                                                break;
                                        case "Paste"    :
-                                               if (HTMLArea.is_opera || (HTMLArea.is_gecko && navigator.productSub < 2008020514)) {
+                                               if (HTMLArea.is_opera || (HTMLArea.is_gecko && navigator.productSub < 20080514)) {
                                                        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) {
@@ -2629,11 +2629,15 @@ HTMLArea._colorToRgb = function(v) {
        return null;
 };
 
-/** Use XML HTTPRequest to post some data back to the server and do something
- * with the response (asyncronously!), this is used by such things as the spellchecker update personal dict function
+/*
+ * Use XML HTTPRequest to post some data back to the server and do something
+ * with the response (asyncronously or syncronously); this is used by such things as the spellchecker update personal dict function
  */
-HTMLArea._postback = function(url, data, handler, addParams, charset) {
+HTMLArea._postback = function(url, data, handler, addParams, charset, asynchronous) {
        if (typeof(charset) == "undefined") var charset = "utf-8";
+       if (typeof(asynchronous) == "undefined") {
+               var asynchronous = true;
+       }
        var req = null;
        if (window.XMLHttpRequest) req = new XMLHttpRequest();
                else if (window.ActiveXObject) {
@@ -2660,24 +2664,38 @@ HTMLArea._postback = function(url, data, handler, addParams, charset) {
                }
 
                function callBack() {
-                       if(req.readyState == 4) {
+                       if (req.readyState == 4) {
                                if (req.status == 200) {
-                                       if (typeof(handler) == 'function') handler(req.responseText, req);
+                                       if (typeof(handler) == "function") handler(req.responseText, req);
                                        HTMLArea._appendToLog("[HTMLArea::_postback]: Server response: " + req.responseText);
                                } else {
                                        HTMLArea._appendToLog("ERROR [HTMLArea::_postback]: Unable to post " + postUrl + " . Server reported " + req.statusText);
                                }
                        }
                }
-               req.onreadystatechange = callBack;
+               if (asynchronous) {
+                       req.onreadystatechange = callBack;
+               }
                function sendRequest() {
                        HTMLArea._appendToLog("[HTMLArea::_postback]: Request: " + content);
                        req.send(content);
                }
 
-               req.open('POST', postUrl, true);
+               req.open('POST', postUrl, asynchronous);
                req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
-               window.setTimeout(sendRequest, 500);
+               if (!asynchronous) {
+                       sendRequest();
+                       if (req.status == 200) {
+                               if (typeof(handler) == "function") {
+                                       handler(req.responseText, req);
+                               }
+                               HTMLArea._appendToLog("[HTMLArea::_postback]: Server response: " + req.responseText);
+                       } else {
+                               HTMLArea._appendToLog("ERROR [HTMLArea::_postback]: Unable to post " + postUrl + " . Server reported " + req.statusText);
+                       }
+               } else {
+                       window.setTimeout(sendRequest, 500);
+               }
        }
 };
 
@@ -3270,11 +3288,15 @@ HTMLArea.Plugin = HTMLArea.Base.extend({
         * @param       string          url: url to post data to
         * @param       object          data: data to be posted
         * @param       function        handler: function that will handle the response returned by the server
+        * @param       boolean         asynchronous: flag indicating if the request should processed asynchronously or not
         *
         * @return      boolean         true on success
         */
-        postData : function (url, data, handler) {
-                HTMLArea._postback(url, data, handler, this.editorConfiguration.RTEtsConfigParams, (this.editorConfiguration.typo3ContentCharset ? this.editorConfiguration.typo3ContentCharset : "utf-8"));
+        postData : function (url, data, handler, asynchronous) {
+                if (typeof(asynchronous) == "undefined") {
+                        var asynchronous = true;
+                }
+                HTMLArea._postback(url, data, handler, this.editorConfiguration.RTEtsConfigParams, (this.editorConfiguration.typo3ContentCharset ? this.editorConfiguration.typo3ContentCharset : "utf-8"), asynchronous);
         },
 
        /**
index 148b888..9a073a7 100644 (file)
@@ -1,7 +1,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2005-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*  (c) 2005-2009 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -99,12 +99,14 @@ TYPO3HtmlParser = HTMLArea.Plugin.extend({
                        editorNo : this.editorNumber,
                        content  : editor._doc.body.innerHTML
                };
+                       // Invoke server-based synchronous pasted content cleaning
                this.postData(  this.parseHtmlModulePath,
                                content,
                                function(response) {
                                        editor.setHTML(response);
                                        editor.selectRange(editor.moveToBookmark(bookmark));
-                               }
+                               },
+                               false
                );
        }
 });