Spaces:
Sleeping
Sleeping
File size: 1,835 Bytes
4024eae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
import { useState } from 'react'
interface EditorModalProps {
open: boolean
onClose: () => void
onDone: (text: string) => void
initialText: string
title: string
sessionId: string
apiBase: string
}
export default function EditorModal({
open,
onClose,
onDone,
initialText,
title,
sessionId: _,
apiBase: __
}: EditorModalProps) {
const [text, setText] = useState(initialText)
if (!open) return null
return (
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50">
<div className="bg-white rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col">
<div className="flex items-center justify-between p-4 border-b">
<h2 className="text-lg font-semibold">{title}</h2>
<button
onClick={onClose}
className="text-gray-500 hover:text-gray-700"
>
✕
</button>
</div>
<div className="flex-1 p-4 overflow-hidden">
<textarea
value={text}
onChange={(e) => setText(e.target.value)}
className="w-full h-full resize-none border rounded p-3 focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="Enter your text here..."
/>
</div>
<div className="flex justify-end gap-2 p-4 border-t">
<button
onClick={onClose}
className="px-4 py-2 text-gray-600 border rounded hover:bg-gray-50"
>
Cancel
</button>
<button
onClick={() => {
onDone(text)
onClose()
}}
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
>
Save
</button>
</div>
</div>
</div>
)
}
|