fix: export highlighter function and rename in composable
This commit is contained in:
parent
98a4e8caaf
commit
406fe18302
|
@ -5,7 +5,7 @@ const shiki = ref<Highlighter>()
|
||||||
const registeredLang = ref(new Map<string, boolean>())
|
const registeredLang = ref(new Map<string, boolean>())
|
||||||
let shikiImport: Promise<void> | undefined
|
let shikiImport: Promise<void> | undefined
|
||||||
|
|
||||||
function useHighlighter(lang: Lang) {
|
export function useHighlighter(lang: Lang) {
|
||||||
if (!shikiImport) {
|
if (!shikiImport) {
|
||||||
shikiImport = import('shiki-es')
|
shikiImport = import('shiki-es')
|
||||||
.then(async (r) => {
|
.then(async (r) => {
|
||||||
|
|
|
@ -45,7 +45,7 @@ function getDecorations({
|
||||||
let from = block.pos + 1
|
let from = block.pos + 1
|
||||||
const language = block.node.attrs.language
|
const language = block.node.attrs.language
|
||||||
|
|
||||||
const shiki = useHightlighter(language)
|
const shiki = useHighlighter(language)
|
||||||
|
|
||||||
if (!shiki)
|
if (!shiki)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue