[BUGFIX] RTE wraps p tags around ol/ul in chrome and opera 56/33656/2
authorStanislas Rolland <typo3@sjbr.ca>
Fri, 31 Oct 2014 04:16:26 +0000 (00:16 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Sat, 1 Nov 2014 15:03:34 +0000 (16:03 +0100)
Releases: master, 6.2
Resolves: #62559
Change-Id: Ib9c0576e82424065e875a73edfa91795c71e841e
Reviewed-on: http://review.typo3.org/33656
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockElements/block-elements.js

index ea5c764..f4e77ea 100644 (file)
@@ -688,7 +688,7 @@ HTMLArea.BlockElements = Ext.extend(HTMLArea.Plugin, {
                        first.innerHTML = '<br />';
                        this.editor.getSelection().selectNodeContents(first, true);
                } else {
-                               // parentElement may be removed by following command
+                       // parentElement may be removed by following command
                        var parentNode = parentElement.parentNode;
                        try {
                                this.editor.getSelection().execCommand(buttonId, false, null);
@@ -696,6 +696,15 @@ HTMLArea.BlockElements = Ext.extend(HTMLArea.Plugin, {
                                this.appendToLog('onButtonPress', e + '\n\nby execCommand(' + buttonId + ');', 'error');
                        }
                        if (Ext.isWebKit || Ext.isOpera) {
+                               // Webkit and Opera may wrap the list inside a paragraph
+                               if (parentElement && /^(p)$/i.test(parentElement.nodeName) && parentElement.firstChild && /^(ol|ul)$/i.test(parentElement.firstChild.nodeName)) {
+                                       // Probably Chrome
+                                       this.editor.getDomNode().removeMarkup(parentElement);
+                               } else if (parentElement.firstChild && /^(p)$/i.test(parentElement.firstChild.nodeName) && parentElement.firstChild.firstChild && /^(ol|ul)$/i.test(parentElement.firstChild.firstChild.nodeName)) {
+                                       // Probably Opera
+                                       this.editor.getDomNode().removeMarkup(parentElement.firstChild);
+                               }
+                               // Webkit and Opera may pollute the list with span tags
                                this.editor.getDomNode().cleanAppleStyleSpans(parentNode);
                        }
                }