'use client';
import dynamic from 'next/dynamic';
import type { SupportedLanguage } from '@/types';
const MonacoEditor = dynamic(() => import('@monaco-editor/react'), {
ssr: false,
loading: () => (
),
});
interface Props {
language: SupportedLanguage;
value: string;
onChange: (value: string) => void;
height?: string;
}
export default function CodeEditor({ language, value, onChange, height = '100%' }: Props) {
const monacoLanguage = language === 'html' ? 'html' : 'python';
return (
onChange(val ?? '')}
options={{
fontSize: 14,
fontFamily: "'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace",
minimap: { enabled: false },
scrollBeyondLastLine: false,
padding: { top: 16, bottom: 16 },
lineNumbersMinChars: 3,
tabSize: 4,
wordWrap: 'on',
smoothScrolling: true,
cursorSmoothCaretAnimation: 'on',
}}
/>
);
}