diff --git a/docs/components/CodeExample.client.vue b/docs/components/CodeExample.client.vue index e902465..162493e 100644 --- a/docs/components/CodeExample.client.vue +++ b/docs/components/CodeExample.client.vue @@ -30,7 +30,7 @@ const stopWatch = watch(el, () => { stopWatch() let ignoreEvent = false - function updateHeight() { + function updateSize() { const width = container.clientWidth const contentHeight = Math.min(1000, editor.getContentHeight()) container.style.height = `${contentHeight}px` @@ -42,29 +42,31 @@ const stopWatch = watch(el, () => { } } + new ResizeObserver(updateSize).observe(el.value) + editor.onDidChangeModelContent(() => { code.value = editor.getValue() - updateHeight() + updateSize() }) function runInsideWorker(code: string) { - var blob = new Blob(["self.onmessage = ", code], { + const blob = new Blob(["self.onmessage = ", code], { type: "text/javascript", }) - var url = URL.createObjectURL(blob) + const url = URL.createObjectURL(blob) } - updateHeight() + updateSize() })