Online Grammar & Spelling Checker

Grammar & Spelling Checker

Improve your writing with AI-powered corrections and suggestions.

An error occurred. The AI may have failed to generate a valid response. Please try again.

`; } finally { loader.classList.add('hidden'); loader.classList.remove('flex'); resultsWrapper.classList.remove('hidden'); } }); const renderResults = (data) => { correctedTextOutput.textContent = data.correctedText; if (data.suggestions && data.suggestions.length > 0) { let tableHTML = ''; data.suggestions.forEach(item => { tableHTML += ``; }); tableHTML += '
OriginalSuggestion
${item.original} ${item.suggestion}
'; suggestionsOutput.innerHTML = tableHTML; } else { suggestionsOutput.innerHTML = '

No specific suggestions were needed. The text looks good!

'; } }; // --- PDF Export --- pdfBtn.addEventListener('click', () => { if (!lastResult) { showMessage('No results to download.', 'error'); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFontSize(18); doc.text('Grammar & Spelling Report', 105, 20, { align: 'center' }); doc.setFontSize(12); doc.setFont(undefined, 'bold'); doc.text('Original Text:', 15, 35); doc.setFont(undefined, 'normal'); let splitText = doc.splitTextToSize(lastResult.originalText, 180); doc.text(splitText, 15, 42); let yPos = 42 + (splitText.length * 5) + 10; doc.setFont(undefined, 'bold'); doc.text('Corrected Text:', 15, yPos); doc.setFont(undefined, 'normal'); splitText = doc.splitTextToSize(lastResult.correctedText, 180); doc.text(splitText, 15, yPos + 7); yPos += 7 + (splitText.length * 5) + 10; if (lastResult.suggestions && lastResult.suggestions.length > 0) { const tableData = lastResult.suggestions.map(s => [s.original, s.suggestion]); doc.autoTable({ startY: yPos, head: [['Original', 'Suggestion']], body: tableData, headStyles: { fillColor: [79, 70, 229] } }); } doc.save('grammar-report.pdf'); }); // --- Utility --- const showMessage = (message, type = 'success') => { messageBox.textContent = message; messageBox.className = `message-box ${type} show`; setTimeout(() => { messageBox.classList.remove('show'); }, 3000); }; });
Scroll to Top