diff --git a/frontend/src/components/session/ExportPreviewModal.tsx b/frontend/src/components/session/ExportPreviewModal.tsx index db742998..d96313fb 100644 --- a/frontend/src/components/session/ExportPreviewModal.tsx +++ b/frontend/src/components/session/ExportPreviewModal.tsx @@ -1,5 +1,5 @@ -import { useState } from 'react' -import { Copy, Download, Check } from 'lucide-react' +import { useState, useEffect } from 'react' +import { Copy, Download, Check, RotateCcw } from 'lucide-react' import { Modal } from '@/components/common/Modal' import { cn } from '@/lib/utils' @@ -9,7 +9,9 @@ interface ExportPreviewModalProps { content: string filename: string format: 'markdown' | 'text' | 'html' | 'psa' - onDownload: () => void + onDownload: (content: string) => void + includeSummary?: boolean + onToggleSummary?: (include: boolean) => void } export function ExportPreviewModal({ @@ -19,12 +21,20 @@ export function ExportPreviewModal({ filename, format, onDownload, + includeSummary = false, + onToggleSummary, }: ExportPreviewModalProps) { const [copied, setCopied] = useState(false) + const [editedContent, setEditedContent] = useState(content) + + // Sync editedContent when content prop changes (new fetch / summary toggle) + useEffect(() => { + setEditedContent(content) + }, [content]) const handleCopy = async () => { try { - await navigator.clipboard.writeText(content) + await navigator.clipboard.writeText(editedContent) setCopied(true) setTimeout(() => setCopied(false), 2000) } catch (err) { @@ -33,39 +43,79 @@ export function ExportPreviewModal({ } const handleDownload = () => { - onDownload() + onDownload(editedContent) onClose() } - // Reset copied state when modal closes + const handleReset = () => { + setEditedContent(content) + } + const handleClose = () => { setCopied(false) onClose() } + const isModified = editedContent !== content + return ( - {/* Filename and format info */} -

- Filename: {filename} - - {format === 'markdown' ? 'Markdown' : format === 'html' ? 'HTML' : 'Plain Text'} - -

- - {/* Content Preview */} -
-
{content}
+ {/* Filename, format info, and controls */} +
+

+ Filename: {filename} + + {format === 'markdown' ? 'Markdown' : format === 'html' ? 'HTML' : format === 'psa' ? 'PSA' : 'Plain Text'} + + {isModified && ( + (edited) + )} +

+
+ {onToggleSummary && ( + + )} + {isModified && ( + + )} +
+ {/* Editable Content */} + +