From: Jason Woofenden Date: Tue, 15 Mar 2016 19:03:25 +0000 (-0400) Subject: adjust to size of content after css loads X-Git-Url: https://jasonwoof.com/gitweb/?p=peach-html5-editor.git;a=commitdiff_plain;h=bf21f4d11feb0738efe013a3a3db1ecc8f3f8787 adjust to size of content after css loads --- diff --git a/editor.coffee b/editor.coffee index cda74ef..5dbc566 100644 --- a/editor.coffee +++ b/editor.coffee @@ -684,8 +684,10 @@ class PeachHTML5Editor # so add a tag @idoc.head.appendChild domify @idoc, base: href: this_url_sans_path() if @options.css_file - # TODO test this - @idoc.head.appendChild domify @idoc, link: rel: 'stylesheet', type: 'text/css', href: @options.css_file + istyle = domify @idoc, link: rel: 'stylesheet', type: 'text/css', href: @options.css_file + '?foo=baz' + istyle.onload = => + @adjust_iframe_height() + @idoc.head.appendChild istyle @idoc.head.appendChild domify @idoc, style: children: [domify @idoc, text: "body { overflow: hidden; }"] @load_html @in_el.value @inited = true @@ -813,6 +815,8 @@ class PeachHTML5Editor @in_el.value = @pretty_html @tree @in_el.onchange = => @load_html @in_el.value + @adjust_iframe_height() + adjust_iframe_height: -> @iframe.style.height = "0" @iframe.style.height = "#{@idoc.body.scrollHeight}px" kill_cursor: -> # remove it, forget where it was