judge/src/constants/editor/themes.ts
ngc2207 0be9cf3baa refactor(constants): move languages.ts and themes.ts to editor folder
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
2024-12-31 23:57:27 +08:00

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);
};