[BUGFIX] RTE: WebKit may insert a span tag when backspacing a heading 86/36086/3
authorStanislas Rolland <typo3@sjbr.ca>
Sat, 17 Jan 2015 19:32:23 +0000 (14:32 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Sat, 17 Jan 2015 19:34:10 +0000 (20:34 +0100)
It may happen, for example, when deleting an empty heading which is
followed by a paragraph, or when backspacing a paragraph or heading
which becomes merged with a preceding heading.
Remove the unwanted span element.

Releases: master, 6.2
Resolves: #59562
Change-Id: I820dfd0e39f2686e07d10b86af6deff59a57cc38
Reviewed-on: http://review.typo3.org/36086
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js

index f709803..c2bb071 100644 (file)
@@ -4275,6 +4275,15 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                                                var node = startContainer.childNodes[startOffset-1];
                                        } else if (/^(body)$/i.test(startContainer.parentNode.nodeName)) {
                                                var node = startContainer;
+                                       // ... or, in Google, a span tag may have been inserted inside a heading element
+                                       } else if (Ext.isWebKit && /^(#text)$/i.test(startContainer.nodeName)) {
+                                               var node = startContainer.parentNode;
+                                               if (/^(h[1-6])$/i.test(node.nodeName)) {
+                                                       self.editor.cleanAppleStyleSpans(node);
+                                               } else if (node.parentNode && /^(h[1-6])$/i.test(node.parentNode.nodeName)) {
+                                                       self.editor.cleanAppleStyleSpans(node.parentNode);
+                                               }
+                                               return false;
                                        } else {
                                                return false;
                                        }
@@ -5116,7 +5125,7 @@ HTMLArea.DOM.Node = Ext.extend(HTMLArea.DOM.Node, {
                                if (HTMLArea.DOM.hasClass(spans[i], 'Apple-style-span')) {
                                        this.removeMarkup(spans[i]);
                                }
-                               if (/^(li)$/i.test(spans[i].parentNode.nodeName) && (spans[i].style.cssText.indexOf('line-height') !== -1 || spans[i].style.cssText.indexOf('font-family') !== -1 || spans[i].style.cssText.indexOf('font-size') !== -1)) {
+                               if (/^(li|h[1-6])$/i.test(spans[i].parentNode.nodeName) && (spans[i].style.cssText.indexOf('line-height') !== -1 || spans[i].style.cssText.indexOf('font-family') !== -1 || spans[i].style.cssText.indexOf('font-size') !== -1)) {
                                        this.removeMarkup(spans[i]);
                                }
                        }