[BUGFIX] RTE: In Chrome RTE inserts weird span tags 92/33392/2
authorStanislas Rolland <typo3@sjbr.ca>
Sun, 19 Oct 2014 18:03:20 +0000 (14:03 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Fri, 24 Oct 2014 14:37:30 +0000 (16:37 +0200)
Remove the span tags inserted by Chrome or Opera on execution of
native execCommand. The attributes of these span tags have evolved...

Releases: master, 6.2
Resolves: #52470
Change-Id: Ibb046b86e869bd7d4afc61ab5005595467b288cd
Reviewed-on: http://review.typo3.org/33392
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockElements/block-elements.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/CopyPaste/copy-paste.js

index 9f968d1..0afdf5a 100644 (file)
@@ -1380,8 +1380,8 @@ HTMLArea.Iframe = Ext.extend(Ext.BoxComponent, {
                                var brNode = editor.document.createElement('br');
                                editor.insertNodeAtSelection(brNode);
                                brNode.parentNode.normalize();
-                                       // Selection issue when an URL was detected
-                               if (editor._unlinkOnUndo) {
+                               // Selection issue when an URL was detected
+                               if (editor.unlinkOnUndo) {
                                        brNode = brNode.parentNode.parentNode.insertBefore(brNode, brNode.parentNode.nextSibling);
                                }
                                if (!brNode.nextSibling || !/\S+/i.test(brNode.nextSibling.textContent)) {
@@ -1392,7 +1392,7 @@ HTMLArea.Iframe = Ext.extend(Ext.BoxComponent, {
                                event.stopEvent();
                        }
                }
-                       // Update the toolbar state after some time
+               // Update the toolbar state after some time
                this.getToolbar().updateLater.delay(200);
                return false;
        },
@@ -5058,24 +5058,26 @@ HTMLArea.DOM.Node = Ext.extend(HTMLArea.DOM.Node, {
         * @return      void
         */
        cleanAppleStyleSpans: function (node) {
-               if (Ext.isWebKit) {
+               if (Ext.isWebKit || Ext.isOpera) {
                        if (node.getElementsByClassName) {
                                var spans = node.getElementsByClassName('Apple-style-span');
                                for (var i = spans.length; --i >= 0;) {
                                        this.removeMarkup(spans[i]);
                                }
-                       } else {
-                               var spans = node.getElementsByTagName('span');
-                               for (var i = spans.length; --i >= 0;) {
-                                       if (HTMLArea.DOM.hasClass(spans[i], 'Apple-style-span')) {
-                                               this.removeMarkup(spans[i]);
-                                       }
+                       }
+                       var spans = node.getElementsByTagName('span');
+                       for (var i = spans.length; --i >= 0;) {
+                               if (HTMLArea.DOM.hasClass(spans[i], 'Apple-style-span')) {
+                                       this.removeMarkup(spans[i]);
                                }
-                               var fonts = node.getElementsByTagName('font');
-                               for (i = fonts.length; --i >= 0;) {
-                                       if (HTMLArea.DOM.hasClass(fonts[i], 'Apple-style-span')) {
-                                               this.removeMarkup(fonts[i]);
-                                       }
+                               if (spans[i].style.cssText.indexOf('line-height') !== -1) {
+                                       this.removeMarkup(spans[i]);
+                               }
+                       }
+                       var fonts = node.getElementsByTagName('font');
+                       for (i = fonts.length; --i >= 0;) {
+                               if (HTMLArea.DOM.hasClass(fonts[i], 'Apple-style-span')) {
+                                       this.removeMarkup(fonts[i]);
                                }
                        }
                }
index 7046215..ea5c764 100644 (file)
@@ -695,7 +695,7 @@ HTMLArea.BlockElements = Ext.extend(HTMLArea.Plugin, {
                        } catch(e) {
                                this.appendToLog('onButtonPress', e + '\n\nby execCommand(' + buttonId + ');', 'error');
                        }
-                       if (Ext.isWebKit) {
+                       if (Ext.isWebKit || Ext.isOpera) {
                                this.editor.getDomNode().cleanAppleStyleSpans(parentNode);
                        }
                }
index 4bcbe6a..2c3624d 100644 (file)
@@ -210,10 +210,12 @@ HTMLArea.CopyPaste = Ext.extend(HTMLArea.Plugin, {
                                }
                        }
                }
-               if (Ext.isWebKit) {
-                               // Remove Apple's span and font tags
+               if (Ext.isWebKit || Ext.isOpera) {
+                       // Remove Apple's span and font tags
                        this.editor.getDomNode().cleanAppleStyleSpans(this.editor.document.body);
-                               // Reset Safari selection in order to prevent insertion of span and/or font tags on next text input
+               }
+               if (Ext.isWebKit) {
+                       // Reset Safari selection in order to prevent insertion of span and/or font tags on next text input
                        var bookmark = this.editor.getBookMark().get(this.editor.getSelection().createRange());
                        this.editor.getSelection().selectRange(this.editor.getBookMark().moveTo(bookmark));
                }