Index: typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js (révision 8908)
+++ typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js (copie de travail)
@@ -658,7 +658,7 @@
}
p = df.firstChild;
if (p) {
- if (!/\S/.test(p.innerHTML) || (p.childNodes.length == 1 && /^br$/i.test(p.firstChild.nodeName))) {
+ if (!/\S/.test(p.innerHTML) || (!/\S/.test(p.textContent) && !/<(img|hr|table)/i.test(p.innerHTML))) {
if (/^h[1-6]$/i.test(p.nodeName)) {
p = this.convertNode(p, "p");
}
@@ -668,7 +668,7 @@
if (!Ext.isOpera) {
p.innerHTML = "
";
}
- if(/^li$/i.test(p.nodeName) && left_empty && !block.nextSibling) {
+ if (/^li$/i.test(p.nodeName) && left_empty && (!block.nextSibling || !/^li$/i.test(block.nextSibling.nodeName))) {
left = block.parentNode;
left.removeChild(block);
range.setEndAfter(left);
@@ -688,8 +688,15 @@
if (a && /^a$/i.test(a.nodeName) && !/\S/.test(a.innerHTML)) {
this.convertNode(a, 'br');
}
+ // Walk inside the deepest child element (presumably inline element)
+ while (p.firstChild && p.firstChild.nodeType == 1 && !/^(br|img|hr|table)$/i.test(p.firstChild.nodeName)) {
+ p = p.firstChild;
+ }
if (/^br$/i.test(p.nodeName)) {
- p = p.parentNode.insertBefore(this._doc.createTextNode("\x20"), p);
+ p = p.parentNode.insertBefore(doc.createTextNode('\x20'), p);
+ } else if (!/\S/.test(p.innerHTML)) {
+ // Need some element inside the deepest element
+ p.appendChild(doc.createElement('br'));
}
this.selectNodeContents(p, true);
} else {