From 6a5b6fd1917693f01459b9ac94e6f3b39257dde2 Mon Sep 17 00:00:00 2001 From: KawaiiZapic Date: Tue, 14 May 2024 15:50:53 +0800 Subject: [PATCH] fix: editor may ran into error if network is slow --- src/pages/post/code-block.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/post/code-block.ts b/src/pages/post/code-block.ts index 5c1756a..0eb41b2 100644 --- a/src/pages/post/code-block.ts +++ b/src/pages/post/code-block.ts @@ -145,7 +145,11 @@ function bindTextarea( }); area.addEventListener("input", () => { const { Highlighter } = window.__MATECHO_OPTIONS__; - if (Highlighter === "Shiki" && shikiInst) { + if ( + Highlighter === "Shiki" && + shikiInst && + shikiInst.getLoadedLanguages().includes(lang) + ) { codeEl.innerHTML = /([\s\S]*?)<\/code>/.exec( shikiInst.codeToHtml(area.value, { lang,