enc_attr_regex = new RegExp('(&)|(")|(\u00A0)', 'g')
function enc_attr (txt) {
return txt.replace(enc_attr_regex, function(match, amp, quote) {
enc_attr_regex = new RegExp('(&)|(")|(\u00A0)', 'g')
function enc_attr (txt) {
return txt.replace(enc_attr_regex, function(match, amp, quote) {
enc_text_regex = new RegExp('(&)|(<)|(\u00A0)', 'g')
function enc_text (txt) {
return txt.replace(enc_text_regex, function(match, amp, lt) {
enc_text_regex = new RegExp('(&)|(<)|(\u00A0)', 'g')
function enc_text (txt) {
return txt.replace(enc_text_regex, function(match, amp, lt) {
- ret += enc_text(n.text)
+ if (n.parent != null ? plaintext_elements[n.parent.name] : false) {
+ ret += n.text
+ } else if (n.parent != null ? newline_eating_elements[n.parent.name] && n.text.charAt(0) === "\n" : false) {
+ ret += enc_text("\n" + n.text)
+ } else {
+ ret += enc_text(n.text)
+ }
// on_init: callback for when the editable content is in place
var css, opt_fragment, outer_bounds, outer_iframe_style, outer_wrap
this.options = options != null ? options : {}
// on_init: callback for when the editable content is in place
var css, opt_fragment, outer_bounds, outer_iframe_style, outer_wrap
this.options = options != null ? options : {}
this.in_el = in_el
this.tree = null // array of Nodes, all editable content
this.tree_parent = null // this.tree is this.children. .el might === this.idoc.body
this.in_el = in_el
this.tree = null // array of Nodes, all editable content
this.tree_parent = null // this.tree is this.children. .el might === this.idoc.body
- this.in_el.value = this.pretty_html(this.tree)
- // TODO make option for not pretty-printing: nodes_to_html(tree)
+ if (this.pretty_print) {
+ this.in_el.value = this.pretty_html(this.tree)
+ } else {
+ this.in_el.value = nodes_to_html(this.tree)
+ }
this.in_el.onchange = (function(_this) { return function() {
return _this.load_html(_this.in_el.value)
}})(this)
this.in_el.onchange = (function(_this) { return function() {
return _this.load_html(_this.in_el.value)
}})(this)
- ret += enc_text(n.text)
+ if (n.parent != null ? plaintext_elements[n.parent.name] : false) {
+ ret += n.text
+ } else if (n.parent != null ? newline_eating_elements[n.parent.name] && n.text.charAt(0) === "\n" : false) {
+ ret += enc_text("\n" + n.text)
+ } else {
+ ret += enc_text(n.text)
+ }