From 16b8d4ef12190d460d174a12cae40f47880810f4 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 29 Dec 2023 20:03:54 +0100 Subject: [PATCH] Slight performance tweaks --- web/client.ts | 6 +++--- web/cm_plugins/markdown_widget.ts | 5 ++++- web/styles/editor.scss | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/web/client.ts b/web/client.ts index a5ad4cc..cdd97d7 100644 --- a/web/client.ts +++ b/web/client.ts @@ -1028,7 +1028,7 @@ export class Client { console.error, ); console.log("Flushed image height cache to store"); - }, 5000); + }, 2000); setCachedImageHeight(url: string, height: number) { this.imageHeightCache.set(url, height); @@ -1047,7 +1047,7 @@ export class Client { console.error, ); // console.log("Flushed widget height cache to store"); - }, 5000); + }, 2000); setCachedWidgetHeight(bodyText: string, height: number) { this.widgetHeightCache.set(bodyText, height); @@ -1063,7 +1063,7 @@ export class Client { console.error, ); console.log("Flushed widget cache to store"); - }, 5000); + }, 2000); setWidgetCache(key: string, cacheItem: WidgetCacheItem) { this.widgetCache.set(key, cacheItem); diff --git a/web/cm_plugins/markdown_widget.ts b/web/cm_plugins/markdown_widget.ts index ad19e0d..570aa00 100644 --- a/web/cm_plugins/markdown_widget.ts +++ b/web/cm_plugins/markdown_widget.ts @@ -54,7 +54,10 @@ export class MarkdownWidget extends WidgetType { activeWidgets.add(this); if (!widgetContent) { div.innerHTML = ""; - // div.style.display = "none"; + this.client.setWidgetCache( + this.bodyText, + { height: div.clientHeight, html: "" }, + ); return; } const lang = buildMarkdown(this.client.system.mdExtensions); diff --git a/web/styles/editor.scss b/web/styles/editor.scss index 1b5a2cc..8c0d113 100644 --- a/web/styles/editor.scss +++ b/web/styles/editor.scss @@ -468,7 +468,7 @@ .sb-markdown-widget, .sb-markdown-top-widget:has(*), .sb-markdown-bottom-widget:has(*) { - overflow-y: scroll; + overflow-y: auto; border: 1px solid var(--editor-directive-background-color); border-radius: 5px; white-space: wrap;