From bf21f4d11feb0738efe013a3a3db1ecc8f3f8787 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Tue, 15 Mar 2016 15:03:25 -0400 Subject: [PATCH] adjust to size of content after css loads --- editor.coffee | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 -- 1.7.10.4