X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Roo%2Fhtmleditor%2FTidyWriter.js;h=e4ca3a0dc5995cab0ef203c11df367e42820c4ef;hb=739a73d3f84bfd246925f61b49ef86141072329a;hp=41052673d3fa5bc904fa5e4b21fffa29840d693f;hpb=8ff669da11e253bb25ec37a5dd92515463b35d2c;p=roojs1 diff --git a/Roo/htmleditor/TidyWriter.js b/Roo/htmleditor/TidyWriter.js index 41052673d3..e4ca3a0dc5 100644 --- a/Roo/htmleditor/TidyWriter.js +++ b/Roo/htmleditor/TidyWriter.js @@ -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. + * - long text inside of inline can be wrapped and clened? + * + * */ Roo.htmleditor.TidyWriter = function(settings) @@ -66,11 +72,16 @@ Roo.htmleditor.TidyWriter.prototype = { var is_short = empty ? Roo.htmleditor.TidyWriter.shortend_elements.indexOf(name) > -1 : false; + var i_inline = name == 'BR' ? false : in_inline; - var indentstr = in_inline || this.in_pre ? '' : this.indentstr; + var indentstr = i_inline || this.in_pre ? '' : this.indentstr; + + // e_inline = elements that can be inline, but still allow \n before and after? + // only 'BR' ??? any others? + var e_inline = name == 'BR' ? false : this.in_inline; // if this element is inline - then don't add stuff beforehand.. - if (!in_inline && !this.in_pre) { + if (!e_inline && !this.in_pre) { this.addLine(); } @@ -89,8 +100,9 @@ Roo.htmleditor.TidyWriter.prototype = { } else { this.html[this.html.length] = '>'; } + var e_inline = name == 'BR' ? false : this.in_inline; - if (!this.in_inline && !this.in_pre) { + if (!e_inline && !this.in_pre) { this.addLine(); } return; @@ -171,9 +183,12 @@ Roo.htmleditor.TidyWriter.prototype = { this.html[this.html.length] = text; return; } - // see if last line is a line break + // 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) { + if (node.previousSibling && + node.previousSibling.nodeType == 1 && + Roo.htmleditor.TidyWriter.inline_elements.indexOf(node.previousSibling.nodeName) > -1) + { indentstr = ''; } else { this.addLine();