* Fixed bug #7755: htmlArea RTE: incorrect handling of enter key in definition lists
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 5 Mar 2008 02:14:44 +0000 (02:14 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Wed, 5 Mar 2008 02:14:44 +0000 (02:14 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3385 709f56b5-9817-0410-a4d7-c38de5d9e867

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

index 1e4b08d..9b6fada 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2008-03-04  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #7754: htmlArea RTE: Caption should be first element in table
+       * Fixed bug #7755: htmlArea RTE: incorrect handling of enter key in definition lists
 
 2008-03-03  Ingo Renner  <ingo@typo3.org>
 
index cc6c6da..b4b16fd 100644 (file)
@@ -1,6 +1,7 @@
 2008-03-04  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #7754: htmlArea RTE: Caption should be first element in table
+       * Fixed bug #7755: htmlArea RTE: incorrect handling of enter key in definition lists
 
 2008-03-02  Stanislas Rolland  <typo3@sjbr.ca>
 
index f07e9a2..90c2e4a 100644 (file)
@@ -3,7 +3,7 @@
 *
 *  (c) 2002-2004, interactivetools.com, inc.
 *  (c) 2003-2004 dynarch.com
-*  (c) 2004-2007 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2004-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -605,12 +605,12 @@ HTMLArea.prototype._checkInsertP = function() {
                a       = null,
                doc     = this._doc;
        for (i = 0; i < p.length; ++i) {
-               if (HTMLArea.isBlockElement(p[i]) && !/^(html|body|table|tbody|thead|tr)$/i.test(p[i].nodeName)) {
+               if (HTMLArea.isBlockElement(p[i]) && !/^(html|body|table|tbody|thead|tfoot|tr|dl)$/i.test(p[i].nodeName)) {
                        block = p[i];
                        break;
                }
        }
-       if (block && /^(td|th|table|tbody|thead|tr)$/i.test(block.nodeName) && this.config.buttons.table && this.config.buttons.table.disableEnterParagraphs) return false;
+       if (block && /^(td|th|tr|tbody|thead|tfoot|table)$/i.test(block.nodeName) && this.config.buttons.table && this.config.buttons.table.disableEnterParagraphs) return false;
        if (!range.collapsed) {
                range.deleteContents();
        }
@@ -665,10 +665,13 @@ HTMLArea.prototype._checkInsertP = function() {
                }
                p = df.firstChild;
                if (p) {
-                       if (!/\S/.test(p.innerHTML)) {
+                       if (!/\S/.test(p.textContent)) {
                                if (/^h[1-6]$/i.test(p.nodeName)) {
                                        p = this.convertNode(p, "p");
                                }
+                               if (/^(dt|dd)$/i.test(p.nodeName)) {
+                                        p = this.convertNode(p, (p.nodeName.toLowerCase() === "dt") ? "dd" : "dt");
+                               }
                                if (!HTMLArea.is_opera) {
                                        p.innerHTML = "<br />";
                                }
@@ -688,8 +691,8 @@ HTMLArea.prototype._checkInsertP = function() {
                        }
                        this.selectNodeContents(p, true);
                } else {
-                       if (block.nodeName.toLowerCase() === "li") {
-                               p = doc.createElement("li");
+                       if (/^(li|dt|dd)$/i.test(block.nodeName)) {
+                               p = doc.createElement(block.nodeName);
                        } else {
                                p = doc.createElement("p");
                        }
index c0d15de..54f6d29 100644 (file)
@@ -818,6 +818,35 @@ BlockElements = HTMLArea.Plugin.extend({
        },
        
        /*
+        * This function gets called by the main editor event handler when a key was pressed.
+        * It will process the enter key for IE when the cursor is at the end of a dt or a dd element
+        */
+       onKeyPress : function (ev) {
+               if (HTMLArea.is_ie && ev.keyCode == 13 && !ev.shiftKey) {
+                       var selection = this.editor._getSelection();
+                       if (this.editor._selectionEmpty(selection)) {
+                               var range = this.editor._createRange(selection);
+                               var parentElement = this.editor.getParentElement(selection, range);
+                               while (parentElement && !HTMLArea.isBlockElement(parentElement)) {
+                                       parentElement = parentElement.parentNode;
+                               }
+                               if (/^(dt|dd)$/i.test(parentElement.nodeName)) {
+                                       var nodeRange = this.editor._createRange();
+                                       nodeRange.moveToElementText(parentElement);
+                                       range.setEndPoint("EndToEnd", nodeRange);
+                                       if (!range.text || range.text == "\x20") {
+                                               var item = parentElement.parentNode.insertBefore(this.editor._doc.createElement((parentElement.nodeName.toLowerCase() === "dt") ? "dd" : "dt"), parentElement.nextSibling);
+                                               item.innerHTML = "\x20";
+                                               this.editor.selectNodeContents(item, true);
+                                               return false;
+                                       }
+                               }
+                       }
+               }
+               return true;
+       },
+       
+       /*
         * This function gets called when the toolbar is updated
         */
        onUpdateToolbar : function () {