fix: trigger code block highlighting when the highlighter is ready (#2539)
This commit is contained in:
parent
e43993770d
commit
77588c1890
4 changed files with 45 additions and 41 deletions
|
@ -7,11 +7,13 @@ export const shikijiParser: Parser = (options) => {
|
|||
const lang = options.language ?? 'text'
|
||||
|
||||
// Register the language if it's not yet registered
|
||||
const highlighter = useHighlighter(lang as BuiltinLanguage)
|
||||
const { highlighter, promise } = useHighlighter(lang as BuiltinLanguage)
|
||||
|
||||
// If the language is not loaded, we return an empty set of decorations
|
||||
// If the highlighter or the language is not available, return a promise that
|
||||
// will resolve when it's ready. When the promise resolves, the editor will
|
||||
// re-parse the code block.
|
||||
if (!highlighter)
|
||||
return []
|
||||
return promise ?? []
|
||||
|
||||
if (!parser)
|
||||
parser = createParser(highlighter)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue