Fixed bug #16675: htmlArea RTE: Incorrect result when inserting horizontal rule in...
authorStanislas Rolland <typo3@sjbr.ca>
Sun, 5 Dec 2010 03:04:14 +0000 (03:04 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Sun, 5 Dec 2010 03:04:14 +0000 (03:04 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-4@9757 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockElements/block-elements.js

index ebed1e1..1653868 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-12-04  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #16675: htmlArea RTE: Incorrect result when inserting horizontal rule in FF and WebKit
+
 2010-12-01  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #16058: htmlArea RTE: Overlay to choose a color exceeds the viewport if many colors are defined
index cecc79c..da53ca3 100644 (file)
@@ -1,3 +1,7 @@
+2010-12-04  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #16675: htmlArea RTE: Incorrect result when inserting horizontal rule in FF and WebKit
+
 2010-12-01  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #16058: htmlArea RTE: Overlay to choose a color exceeds the viewport if many colors are defined
index 0971af7..60cae0c 100644 (file)
@@ -544,7 +544,7 @@ HTMLArea.BlockElements = HTMLArea.Plugin.extend({
                                this.insertList(buttonId, parentElement);
                                break;
                        case "InsertHorizontalRule":
-                               this.editor.execCommand('InsertHorizontalRule');
+                               this.insertHorizontalRule();
                                break;
                        case "none" :
                                if (this.isAllowedBlockElement(parentElement.nodeName)) {
@@ -933,6 +933,49 @@ HTMLArea.BlockElements = HTMLArea.Plugin.extend({
                }
        },
        /*
+        * Insert horizontal line
+        */
+       insertHorizontalRule: function() {
+               this.editor.execCommand('InsertHorizontalRule');
+                       // Apply enterParagraphs rule
+               if (!Ext.isIE && !Ext.isOpera && !this.editor.config.disableEnterParagraphs) {
+                       var range = this.editor._createRange(this.editor._getSelection());
+                       var startContainer = range.startContainer;
+                       if (/^body$/i.test(startContainer.nodeName)) {
+                               startContainer.normalize();
+                               var ruler = startContainer.childNodes[range.startOffset-1];
+                               if (ruler.nextSibling) {
+                                       if (ruler.nextSibling.nodeType == 3) {
+                                               if (/\S/.test(ruler.nextSibling.textContent)) {
+                                                       var paragraph = this.editor.document.createElement('p');
+                                                       paragraph = startContainer.appendChild(paragraph);
+                                                       paragraph = startContainer.insertBefore(paragraph, ruler.nextSibling);
+                                                       paragraph.appendChild(ruler.nextSibling);
+                                               } else {
+                                                       HTMLArea.removeFromParent(ruler.nextSibling);
+                                                       var paragraph = ruler.nextSibling;
+                                               }
+                                       } else {
+                                               var paragraph = ruler.nextSibling;
+                                       }
+                                               // Cannot set the cursor on the hr element
+                                       if (/^hr$/i.test(paragraph.nodeName)) {
+                                               var inBetweenParagraph = this.editor.document.createElement('p');
+                                               inBetweenParagraph.innerHTML = '<br />';
+                                               paragraph = startContainer.insertBefore(inBetweenParagraph, paragraph);
+                                       }
+                               } else {
+                                       var paragraph = this.editor.document.createElement('p');
+                                       if (Ext.isWebKit) {
+                                               paragraph.innerHTML = '<br />';
+                                       }
+                                       paragraph = startContainer.appendChild(paragraph);
+                               }
+                               this.editor.selectNodeContents(paragraph, true);
+                       }
+               }
+       },
+       /*
         * This function gets called when the plugin is generated
         */
        onGenerate: function () {