import CodeMirror from "@uiw/react-codemirror";
import { markdown } from "@codemirror/lang-markdown";
import { duotoneDark } from "@uiw/codemirror-theme-duotone";

interface TextEditorProps {
  value: string;
  onChange: (value: string) => void;
}

export const TextEditor: React.FC<TextEditorProps> = ({ value, onChange }) => {
  return (
    <CodeMirror
      value={value}
      extensions={[markdown({ extensions: [] })]}
      onChange={(value, _viewUpdate) => {
        onChange(value);
      }}
      theme={duotoneDark}
    />
  );
};
