From 3535bc94497bc3efc5abd3176a645d0748fe1cf3 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Tue, 3 Oct 2023 14:34:07 +0200 Subject: [PATCH] Improved cached widget height --- web/cm_plugins/fenced_code.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/cm_plugins/fenced_code.ts b/web/cm_plugins/fenced_code.ts index fae524b0..645bd5c0 100644 --- a/web/cm_plugins/fenced_code.ts +++ b/web/cm_plugins/fenced_code.ts @@ -52,13 +52,15 @@ class IFrameWidget extends WidgetType { }, ); + iframe.style.height = `${this.estimatedHeight}px`; + return iframe; } get estimatedHeight(): number { const cachedHeight = this.editor.space.getCachedWidgetHeight(this.bodyText); - // console.log("Calling estimated height", cachedHeight); - return cachedHeight || 150; + console.log("Calling estimated height", cachedHeight); + return cachedHeight > 0 ? cachedHeight : 150; } eq(other: WidgetType): boolean {