Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion backend/src/controllers/exportController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ export const handleExport = async (req: Request, res: Response) => {
buffer = await generateDocxBuffer(text);
contentType = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
extension = 'docx';
} else if (format === 'txt') {
buffer = Buffer.from(text, 'utf-8');
contentType = 'text/plain';
extension = 'txt';
} else {
return res.status(400).json({ error: 'Invalid export format. Use "pdf" or "docx".' });
return res.status(400).json({ error: 'Invalid export format. Use "pdf", "docx", or "txt".' });
}

const downloadName = `${fileName || 'humanized_text'}.${extension}`;
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function App() {
setTimeout(() => setCopySuccess(false), 2000);
};

const handleExport = async (format: 'pdf' | 'docx') => {
const handleExport = async (format: 'pdf' | 'docx' | 'txt') => {
if (!humanizedText) {
alert('Please generate content first before exporting.');
return;
Expand Down Expand Up @@ -400,11 +400,18 @@ function App() {
</button>
<button
onClick={() => handleExport('docx')}
className="flex items-center gap-2 px-4 py-2 text-xs font-bold text-slate-700 hover:bg-slate-50 hover:text-indigo-600 transition-all active:scale-95"
className="flex items-center gap-2 px-4 py-2 text-xs font-bold text-slate-700 hover:bg-slate-50 hover:text-indigo-600 transition-all border-r border-slate-100 active:scale-95"
>
<FileText size={14} />
Export DOCX
</button>
<button
onClick={() => handleExport('txt')}
className="flex items-center gap-2 px-4 py-2 text-xs font-bold text-slate-700 hover:bg-slate-50 hover:text-indigo-600 transition-all active:scale-95"
>
<FileText size={14} />
Export TXT
</button>
</div>
<button
onClick={() => setView('security')}
Expand Down