"use client" import type React from "react" import { useEffect, useRef } from "react" interface MarkdownInputProps { content: string onChange: (content: string) => void onTextareaRef: (ref: HTMLTextAreaElement | null) => void } export function MarkdownInput({ content, onChange, onTextareaRef }: MarkdownInputProps) { const textareaRef = useRef(null) useEffect(() => { onTextareaRef(textareaRef.current) }, [onTextareaRef]) const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Tab") { e.preventDefault() const start = e.currentTarget.selectionStart const end = e.currentTarget.selectionEnd const newContent = content.substring(0, start) + " " + content.substring(end) onChange(newContent) setTimeout(() => { if (textareaRef.current) { textareaRef.current.setSelectionRange(start + 2, start + 2) } }, 0) } } return (