mirror of
https://litchi.icu/ngc2207/judge.git
synced 2025-05-20 16:33:07 +00:00
refactor(imports): update SUPPORTED_LANGUAGES and SUPPORTED_THEMES import path to use editor folder feat(constants): add MIN_FONT_SIZE、MAX_FONT_SIZE and DEFAULT_FONT_SIZE feat(store): add font size management to code editor store
33 lines
836 B
TypeScript
33 lines
836 B
TypeScript
import { createHighlighter } from "shiki";
|
|
import { Monaco } from "@monaco-editor/react";
|
|
import { shikiToMonaco } from "@shikijs/monaco";
|
|
import { SUPPORTED_LANGUAGES } from "./languages";
|
|
|
|
export const SUPPORTED_THEMES = [
|
|
{
|
|
key: "vitesse-dark",
|
|
value: "vitesse-dark",
|
|
label: "Vitesse Dark",
|
|
},
|
|
{
|
|
key: "vitesse-light",
|
|
value: "vitesse-light",
|
|
label: "Vitesse Light",
|
|
},
|
|
];
|
|
|
|
export const DEFAULT_THEME = SUPPORTED_THEMES[0].value;
|
|
|
|
export const highlightMonacoEditor = async (monaco: Monaco) => {
|
|
const highlighter = await createHighlighter({
|
|
themes: SUPPORTED_THEMES.map((theme) => theme.key),
|
|
langs: SUPPORTED_LANGUAGES.map((lang) => lang.key),
|
|
});
|
|
|
|
for (const lang of SUPPORTED_LANGUAGES) {
|
|
monaco.languages.register({ id: lang.key });
|
|
}
|
|
|
|
shikiToMonaco(highlighter, monaco);
|
|
};
|