Fixed bug #14106: htmlArea RTE: ENTER after an image at beginning of block deletes...
authorStanislas Rolland <typo3@sjbr.ca>
Tue, 20 Apr 2010 03:56:32 +0000 (03:56 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 20 Apr 2010 03:56:32 +0000 (03:56 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7399 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js

index 8c17dda..b469635 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
 2010-04-19  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #14153: htmlAreaRTE: Some Page TSConfig may break default hotkey assignments
+       * Fixed bug #14106: htmlArea RTE: ENTER after an image at beginning of block deletes the image
 
 2010-04-19  Steffen Kamper  <info@sk-typo3.de>
 
index 80d4899..59671d0 100644 (file)
@@ -1,6 +1,7 @@
 2010-04-19  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #14153: htmlAreaRTE: Some Page TSConfig may break default hotkey assignments
+       * Fixed bug #14106: htmlArea RTE: ENTER after an image at beginning of block deletes the image
 
 2010-04-14  Stanislas Rolland  <typo3@sjbr.ca>
 
index f298679..bd7a18d 100644 (file)
@@ -598,7 +598,7 @@ HTMLArea.Editor.prototype._checkInsertP = function() {
        } else {
                range.setEndAfter(block);
                var df = range.extractContents(), left_empty = false;
-               if (!/\S/.test(block.innerHTML)) {
+               if (!/\S/.test(block.innerHTML) || (!/\S/.test(block.textContent) && !/<(img|hr|table)/i.test(block.innerHTML))) {
                        if (!Ext.isOpera) {
                                block.innerHTML = "<br />";
                        }
@@ -606,7 +606,7 @@ HTMLArea.Editor.prototype._checkInsertP = function() {
                }
                p = df.firstChild;
                if (p) {
-                       if (!/\S/.test(p.textContent)) {
+                       if (!/\S/.test(p.innerHTML) || (p.childNodes.length == 1 && /^br$/i.test(p.firstChild.nodeName))) {
                                if (/^h[1-6]$/i.test(p.nodeName)) {
                                        p = this.convertNode(p, "p");
                                }
@@ -625,20 +625,17 @@ HTMLArea.Editor.prototype._checkInsertP = function() {
                                }
                        }
                        range.insertNode(df);
-                               // Remove any anchor created empty
+                               // Remove any anchor created empty on both sides of the selection
                        if (p.previousSibling) {
                                var a = p.previousSibling.lastChild;
                                if (a && /^a$/i.test(a.nodeName) && !/\S/.test(a.innerHTML)) {
-                                       if (Ext.isOpera) {
-                                               this.removeMarkup(a);
-                                       } else {
-                                               HTMLArea.removeFromParent(a);
-                                       }
-                               }
-                               if (!/\S/.test(p.previousSibling.textContent) && !Ext.isOpera) {
-                                       p.previousSibling.innerHTML = "<br />";
+                                       this.convertNode(a, 'br');
                                }
                        }
+                       var a = p.lastChild;
+                       if (a && /^a$/i.test(a.nodeName) && !/\S/.test(a.innerHTML)) {
+                               this.convertNode(a, 'br');
+                       }
                        if (/^br$/i.test(p.nodeName)) {
                                p = p.parentNode.insertBefore(this._doc.createTextNode("\x20"), p);
                        }