diff --git a/src/sandbox/index.js b/src/sandbox/index.js index a3d63d9..8cf8248 100644 --- a/src/sandbox/index.js +++ b/src/sandbox/index.js @@ -192,7 +192,7 @@ class Sandbox extends Component { contentLoaded(ev) { let elem = ev.target let body = elem.contentDocument.body - elem.style.height = body.clientHeight + 'px' + elem.style.height = body.scrollHeight + 10 + 'px' } renderTemplate() { @@ -207,9 +207,17 @@ class Sandbox extends Component { mounted() { // - this.#cache.preview.panel = this.$refs.preview + let target = this.$refs.preview + this.#cache.preview.panel = target this.renderTemplate() - this.$refs.preview.style.display = 'block' + target.style.display = 'block' + + this.__observer = new ResizeObserver(_ => this.contentLoaded({ target })) + this.__observer.observe(target.contentDocument.body) + } + + unmounted() { + this.__observer?.disconnect() } render() {