Skip to content

Commit

Permalink
fix: editor may ran into error if network is slow
Browse files Browse the repository at this point in the history
  • Loading branch information
KawaiiZapic committed May 14, 2024
1 parent 848c90e commit 6a5b6fd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pages/post/code-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = /<code>([\s\S]*?)<\/code>/.exec(
shikiInst.codeToHtml(area.value, {
lang,
Expand Down

0 comments on commit 6a5b6fd

Please sign in to comment.