1a8243f1ca
* (swap) prism -> shiki * fix styles * (bump) aiscript-vscode to v0.0.5 * refactor * replace prism-editor (beta) * Update scratchpad.vue * (enhance) MkCodeEditor自動インデント改行 * (fix) lint * (add) scratchpad: MkStickyContainer * Update CHANGELOG.md * clean up --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
31 lines
698 B
TypeScript
31 lines
698 B
TypeScript
import { setWasm, setCDN, Highlighter, getHighlighter as _getHighlighter } from 'shiki';
|
|
|
|
setWasm('/assets/shiki/dist/onig.wasm');
|
|
setCDN('/assets/shiki/');
|
|
|
|
let _highlighter: Highlighter | null = null;
|
|
|
|
export async function getHighlighter(): Promise<Highlighter> {
|
|
if (!_highlighter) {
|
|
return await initHighlighter();
|
|
}
|
|
return _highlighter;
|
|
}
|
|
|
|
export async function initHighlighter() {
|
|
const highlighter = await _getHighlighter({
|
|
theme: 'dark-plus',
|
|
langs: ['js'],
|
|
});
|
|
|
|
await highlighter.loadLanguage({
|
|
path: 'languages/aiscript.tmLanguage.json',
|
|
id: 'aiscript',
|
|
scopeName: 'source.aiscript',
|
|
aliases: ['is', 'ais'],
|
|
});
|
|
|
|
_highlighter = highlighter;
|
|
|
|
return highlighter;
|
|
}
|