import classNames from 'classnames'; import { useRef, useState } from 'react'; import type { EditorProps } from './core/Editor/Editor'; import { Editor } from './core/Editor/LazyEditor'; import { SegmentedControl } from './core/SegmentedControl'; import { Markdown } from './Markdown'; type ViewMode = 'edit' | 'preview'; interface Props extends Pick { placeholder: string; className?: string; editorClassName?: string; defaultValue: string; onChange: (value: string) => void; name: string; } export function MarkdownEditor({ className, editorClassName, defaultValue, onChange, name, forceUpdateKey, ...editorProps }: Props) { const [viewMode, setViewMode] = useState(defaultValue ? 'preview' : 'edit'); const containerRef = useRef(null); const editor = ( ); const preview = defaultValue.length === 0 ? (

No description

) : (
{defaultValue}
); const contents = viewMode === 'preview' ? preview : editor; return (
{contents}
); }