"use client"; import { useRef } from "react"; import "@fontsource-variable/fira-code"; import { createHighlighter } from "shiki"; import type { editor } from "monaco-editor"; import { shikiToMonaco } from "@shikijs/monaco"; import { useCodeEditorStore } from "@/store/codeEditorStore"; import MonacoEditor, { type Monaco } from "@monaco-editor/react"; export function CodeEditor() { const monacoRef = useRef(null); const editorRef = useRef(null); const { lang, theme, value, isLigature } = useCodeEditorStore(); return ( { editorRef.current = editor; monacoRef.current = monaco; void (async () => { const ADDITIONAL_LANGUAGES = [ "c", "java", ] as const satisfies Parameters[0]["langs"]; for (const lang of ADDITIONAL_LANGUAGES) { monacoRef.current?.languages.register({ id: lang }); } const highlighter = await createHighlighter({ themes: [theme], langs: ADDITIONAL_LANGUAGES, }); shikiToMonaco(highlighter, monacoRef.current); })(); }} /> ); }