JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
adjust to size of content after css loads
authorJason Woofenden <jason@jasonwoof.com>
Tue, 15 Mar 2016 19:03:25 +0000 (15:03 -0400)
committerJason Woofenden <jason@jasonwoof.com>
Tue, 15 Mar 2016 19:03:25 +0000 (15:03 -0400)
editor.coffee

index cda74ef..5dbc566 100644 (file)
@@ -684,8 +684,10 @@ class PeachHTML5Editor
                # so add a <base> 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