import { cn } from 'ui'
import { AddCellDropdown } from './AddCellDropdown'
import { MoveCellDropdownContent } from './MoveCellDropdownContent'
import { MarkdownEditor } from '@/components/ui/MarkdownEditor/MarkdownEditor'
import { SortableSection } from '@/components/ui/SortableSection'
import { type MarkdownCell as MarkdownCellSchema } from '@/data/content/notebooks/notebook-schema'
import { useCurrentNotebook, useNotebooksStateSnapshot } from '@/state/notebooks/notebooks-state'
interface MarkdownCellProps {
cell: MarkdownCellSchema
onEdit?: () => void
}
export const MarkdownCell = ({ cell, onEdit }: MarkdownCellProps) => {
const snap = useNotebooksStateSnapshot()
const currentNotebook = useCurrentNotebook()
const cells = currentNotebook?.notebook.content?.cells ?? []
const handleUpdateMarkdown = (text: string) => {
const notebookId = currentNotebook?.notebook.id
if (!notebookId || text === cell.text) return
onEdit?.()
const nextCells = cells.map((c) => (c._id === cell._id ? { ...c, text } : c))
snap.updateCells({ id: notebookId, cells: nextCells })
}
return (