<!-- source-hash: ffc5aef958faee68b30051c7f83e0b1e -->
A full-featured, theme-aware Markdown editor component wrapping `@uiw/react-md-editor` with Flamingo design system styling, file upload support, and auto-scroll during resize.

## Key Components

### `MarkdownEditor` (default export)
The primary editor component. Dynamically loads the underlying `MDEditor` (SSR-safe) and injects scoped CSS overrides to match Flamingo's design tokens.

### `MarkdownEditorStyles`
Internal component that injects `<style>` into `document.head` once on mount, applying Flamingo theme variables to all `.w-md-editor-*` selectors.

### `MarkdownEditorProps`
| Prop | Type | Description |
|------|------|-------------|
| `value` | `string` | Controlled markdown content |
| `onChange` | `(markdown: string) => void` | Change callback |
| `placeholder` | `string` | Editor placeholder text |
| `disabled` | `boolean` | Disables editing |
| `height` | `number` | Initial height in px (default: `600`) |
| `minHeight` | `number` | Minimum height in px (default: `100`) |
| `onUploadFile` | `(file: File) => Promise<string>` | Upload handler; shows upload button when provided |
| `onFileUploaded` | `(url, filename) => void` | Post-upload callback |
| `renderPreview` | `(source: string) => ReactNode` | Custom preview renderer |

## Usage Example

```typescript
import { MarkdownEditor } from "./markdown-editor"

function MyForm() {
  const [content, setContent] = useState("# Hello")

  const handleUpload = async (file: File): Promise<string> => {
    const formData = new FormData()
    formData.append("file", file)
    const res = await fetch("/api/upload", { method: "POST", body: formData })
    const { url } = await res.json()
    return url
  }

  return (
    <MarkdownEditor
      value={content}
      onChange={setContent}
      placeholder="Write something..."
      height={400}
      onUploadFile={handleUpload}
      onFileUploaded={(url, name) => console.log("Uploaded:", name, url)}
    />
  )
}
```

**Notable behaviors:**
- Pasting an image from clipboard triggers `onUploadFile` automatically
- Uploaded files are inserted as `![name](url)` (images) or `[name](url)` (other)
- The resize drag handle triggers an auto-scroll RAF loop to prevent viewport lock during resize