Skip to content

Commit 7c4827a

Browse files
authored
fix(CodeBlock): skip lang init on import fail (#817)
1 parent 9a3856c commit 7c4827a

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,20 @@ export const CodeBlockHighlight: ExtensionAuto<CodeBlockHighlightOptions> = (bui
6666
key,
6767
state: {
6868
init: (_, state) => {
69-
loadModules().then(() => {
70-
modulesLoaded = true;
71-
72-
for (const lang of Object.keys(langs)) {
73-
const defs = langs[lang](hljs);
74-
selectItems.push({
75-
value: lang,
76-
content: defs.name || capitalize(lang),
77-
});
78-
if (defs.aliases) {
79-
for (const alias of defs.aliases) {
80-
mapping[alias] = lang;
69+
loadModules().then((loaded) => {
70+
modulesLoaded = loaded;
71+
72+
if (modulesLoaded) {
73+
for (const lang of Object.keys(langs)) {
74+
const defs = langs[lang](hljs);
75+
selectItems.push({
76+
value: lang,
77+
content: defs.name || capitalize(lang),
78+
});
79+
if (defs.aliases) {
80+
for (const alias of defs.aliases) {
81+
mapping[alias] = lang;
82+
}
8183
}
8284
}
8385
}

0 commit comments

Comments
 (0)