X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=editor.js;h=104bbae3eb42ba4ecc6aa2773dade9bdf3730013;hb=c753e098069685cae49988ba752a47b2818b1c5b;hp=0c9cf4652e9e87b4c47dd772e7f4c8b1df7146f0;hpb=65ceb13d7a5cbf9bda7995f98bbfb75811a6933b;p=peach-html5-editor.git diff --git a/editor.js b/editor.js index 0c9cf46..104bbae 100644 --- a/editor.js +++ b/editor.js @@ -274,7 +274,7 @@ void_elements = { } // contents are not html encoded -plaintext_elements = { +var plaintext_elements = { style: 1, script: 1, xmp: 1, @@ -286,7 +286,7 @@ plaintext_elements = { } // parser deletes a starting newline inside: -newline_eating_elements = { +var newline_eating_elements = { pre: 1, textarea: 1, listing: 1 @@ -825,39 +825,37 @@ function PeachHTML5Editor (in_el, options) { if (this.options.editor_id != null) { this.outer_iframe.setAttribute('id', this.options.editor_id) } - this.outer_iframe.onload = (function(_this) { - return function() { - var icss - _this.outer_idoc = _this.outer_iframe.contentDocument - icss = domify(_this.outer_idoc, { style: { children: [ - domify(_this.outer_idoc, {text: css}) - ]}}) - _this.outer_idoc.head.appendChild(icss) - _this.iframe = domify(_this.outer_idoc, {iframe: {sandbox: 'allow-same-origin allow-scripts'}}) - _this.iframe.onload = function() { + this.outer_iframe.onload = (function(_this) { return function() { + var icss + _this.outer_idoc = _this.outer_iframe.contentDocument + icss = domify(_this.outer_idoc, { style: { children: [ + domify(_this.outer_idoc, {text: css}) + ]}}) + _this.outer_idoc.head.appendChild(icss) + _this.iframe = domify(_this.outer_idoc, {iframe: {sandbox: 'allow-same-origin allow-scripts'}}) + _this.iframe.onload = function() { + return _this.init_1() + } + timeout(200, function() { // firefox never fires this onload + if (!_this.init_1_called) { return _this.init_1() } - timeout(200, function() { // firefox never fires this onload - if (!_this.init_1_called) { - return _this.init_1() - } - }) - _this.outer_idoc.body.appendChild( - domify(_this.outer_idoc, {div: {id: 'wrap1', children: [ - domify(_this.outer_idoc, {div: { - style: "position: absolute; top: 0; left: 1px; font-size: 10px", - children: [domify(_this.outer_idoc, {text: "Peach HTML5 Editor"})] - }}), - _this.wrap2 = domify(_this.outer_idoc, {div: {id: 'wrap2', children: [ - domify(_this.outer_idoc, {div: {id: 'wrap3', children: [ - _this.iframe, - _this.overlay = domify(_this.outer_idoc, { div: { id: 'overlay' }}) - ]}}) + }) + _this.outer_idoc.body.appendChild( + domify(_this.outer_idoc, {div: {id: 'wrap1', children: [ + domify(_this.outer_idoc, {div: { + style: "position: absolute; top: 0; left: 1px; font-size: 10px", + children: [domify(_this.outer_idoc, {text: "Peach HTML5 Editor"})] + }}), + _this.wrap2 = domify(_this.outer_idoc, {div: {id: 'wrap2', children: [ + domify(_this.outer_idoc, {div: {id: 'wrap3', children: [ + _this.iframe, + _this.overlay = domify(_this.outer_idoc, { div: { id: 'overlay' }}) ]}}) ]}}) - ) - } - })(this) + ]}}) + ) + }})(this) outer_wrap = domify(document, {div: {"class": 'peach_html5_editor' }}) this.in_el.parentNode.appendChild(outer_wrap) outer_bounds = get_el_bounds(outer_wrap) @@ -957,6 +955,7 @@ PeachHTML5Editor.prototype.generate_outer_css = function(args) { ret += 'padding: 0;' ret += 'color: black;' ret += 'background: white;' + ret += 'font-family: sans;' ret += '}' ret += '#wrap1 {' ret += "border: " + (occupy(1)) + "px solid black;" @@ -1833,7 +1832,7 @@ PeachHTML5Editor.prototype.preserve_space = function(n, ideal_target) { PeachHTML5Editor.prototype.update_style_from_el = function(n) { var style style = n.el.getAttribute('style') - if (style != null) { + if (style != null && style != '') { return n.attrs.style = style } else { if (n.attrs.style != null) { @@ -2156,7 +2155,7 @@ PeachHTML5Editor.prototype.text_cleanup = function(n) { } if (need_preserve) { // do we have it already? - ws = this.computed_style(n, 'white-space') // FIXME implement this + ws = this.computed_style(n, 'white-space') if (ws_props[ws] != null ? !ws_props[ws].space : true) { // 2nd arg is ideal target for css rule ws = this.preserve_space(n, block) @@ -2164,7 +2163,7 @@ PeachHTML5Editor.prototype.text_cleanup = function(n) { eats_start_sp = false } else { if (is_space_code(n.text.charCodeAt(n.text.length - 1))) { - ws = this.computed_style(n, 'white-space') // FIXME implement this + ws = this.computed_style(n, 'white-space') if ((ref1 = ws_props[ws]) != null ? ref1.space : void 0) { eats_start_sp = false } else {