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

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

index 248308a..c5b09ed 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 25bf69d..c7cdffe 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 b3d9aca..4d79760 100644 (file)
@@ -2379,11 +2379,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) {
@@ -2410,24 +2414,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);
+               }
        }
 };
 
@@ -3053,11 +3071,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 f7f20c0..2251ed8 100644 (file)
@@ -124,8 +124,9 @@ CopyPaste = HTMLArea.Plugin.extend({
                                                        // If we are handling a button, not a hotkey
                                                this.applyBrowserCommand(buttonId);
                                        }
-                                               // In FF3, the paste operation will indeed trigger the onPaste even; not in FF2; nor in Opera
-                                       if (HTMLArea.is_opera || (HTMLArea.is_gecko && navigator.productSub < 2008020514)) {
+                                               // In FF3, the paste operation will indeed trigger the onPaste event not in FF2; nor in Opera
+                                               // Safari does not support the paste operation
+                                       if (HTMLArea.is_opera || (HTMLArea.is_gecko && navigator.productSub < 20080514)) {
                                                var cleanLaterFunctRef = this.getPluginInstance("DefaultClean") ? this.getPluginInstance("DefaultClean").cleanLaterFunctRef : (this.getPluginInstance("TYPO3HtmlParser") ? this.getPluginInstance("TYPO3HtmlParser").cleanLaterFunctRef : null);
                                                if (cleanLaterFunctRef) {
                                                        window.setTimeout(cleanLaterFunctRef, 50);
index a5c7f4f..5ee648f 100644 (file)
@@ -99,12 +99,14 @@ TYPO3HtmlParser = HTMLArea.Plugin.extend({
                        editorNo : this.editorNumber,
                        content  : this.getPluginInstance("EditorMode").getInnerHTML()
                };
+                       // Server-based synchronous pasted content cleaning
                this.postData(  this.parseHtmlModulePath,
                                content,
                                function(response) {
                                        editor.getPluginInstance("EditorMode").setHTML(response);
                                        editor.selectRange(editor.moveToBookmark(bookmark));
-                               }
+                               },
+                               false
                );
        }
 });