Roo/htmleditor/TidyWriter.js
[roojs1] / Roo / htmleditor / TidyWriter.js
index f7c91ee..4dad02b 100644 (file)
@@ -2,6 +2,12 @@
  * This is based loosely on tinymce 
  * @class Roo.htmleditor.TidyWriter
  * https://github.com/thorn0/tinymce.html/blob/master/tinymce.html.js
+ *
+ * Known issues?
+ * - not tested much with 'PRE' formated elements.
+ * - BR insined inline?
+ *
+ *
  */
 
 Roo.htmleditor.TidyWriter = function(settings)
@@ -169,12 +175,18 @@ Roo.htmleditor.TidyWriter.prototype = {
         }
         if (this.in_pre || this.in_inline) {
             this.html[this.html.length] =  text;
-            return;
-            
+            return;   
+        }
+        // see if last element was a inline element.
+        var indentstr = this.indentstr;
+        if (node.previousSibling &&
+            node.previousSibling.nodeType == 1 &&
+            Roo.htmleditor.TidyWriter.inline_elements.indexOf(node.previousSibling.nodeName) > -1)
+        {
+            indentstr = '';
+        } else {
+            this.addLine();
         }
-        // see if last line is a line break
-        
-        this.addLine();
             
         
         
@@ -186,7 +198,7 @@ Roo.htmleditor.TidyWriter.prototype = {
             return;
         }
         if (!text.match(/\n/)) {
-            this.html.push(this.indentstr + text);
+            this.html.push(indentstr + text);
             return;
         }