From 1c8c5a41f578ccf75dd204d850b0d858cdb8c920 Mon Sep 17 00:00:00 2001
From: llama <100429699+iamllama@users.noreply.github.com>
Date: Tue, 18 Feb 2025 15:41:37 +0800
Subject: [PATCH] Cache rendered mathjax to avoid stalling when editing
plaintext (#3828)
* add lru-cache
* cache mathjax rendering
---
package.json | 1 +
ts/editable/Mathjax.svelte | 34 +++++++++++++++++++++++++++++-----
yarn.lock | 1 +
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index e00ee8307..dcbd24531 100644
--- a/package.json
+++ b/package.json
@@ -75,6 +75,7 @@
"jquery": "^3.5.1",
"jquery-ui-dist": "^1.12.1",
"lodash-es": "^4.17.21",
+ "lru-cache": "^10.2.0",
"marked": "^5.1.0",
"mathjax": "^3.1.2"
},
diff --git a/ts/editable/Mathjax.svelte b/ts/editable/Mathjax.svelte
index f61250559..5fe48a4db 100644
--- a/ts/editable/Mathjax.svelte
+++ b/ts/editable/Mathjax.svelte
@@ -4,6 +4,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->