Text Editor
Online Text Editor, A free online tool to write, edit, and format text instantly. Includes essential editing features for clean, error free, and ready to use text. Fully browser based with no installation required.
Ultra Text Editor
0 words
|
0 characters
|
0 min read
Line 1, Col 1
Upload Image
Upload Text File
Insert Link
Insert Table
Export Document
Theme Settings
Neon
Dark
Light
Ocean
Forest
Sunset
Background Settings
50
Document Statistics
Words: 0
Characters: 0
Characters (no spaces): 0
Sentences: 0
Paragraphs: 0
Reading Time: 0 min
Speaking Time: 0 min
Lorem Ipsum Generator
Random Quotes
Word Frequency
Keyword Highlight
Notification text
`;
const blob = new Blob([html], { type: 'text/html' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.html';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as HTML', 'success');
}
function exportAsPDF() {
const { jsPDF } = window.jspdf;
const pdf = new jsPDF();
const pageSize = document.getElementById('pdfPageSize').value;
const orientation = document.getElementById('pdfOrientation').value;
const pageNumbers = document.getElementById('pdfPageNumbers').checked;
// Set page size and orientation
if (orientation === 'landscape') {
pdf.internal.pageSize.width = pdf.internal.pageSize.getHeight();
pdf.internal.pageSize.height = pdf.internal.pageSize.getWidth();
}
// Get HTML content
const content = editor.innerHTML;
// Create a temporary div to render the content
const tempDiv = document.createElement('div');
tempDiv.innerHTML = content;
tempDiv.style.width = '190mm'; // A4 width minus margins
tempDiv.style.padding = '10mm';
tempDiv.style.fontFamily = 'Arial';
tempDiv.style.fontSize = '12px';
tempDiv.style.lineHeight = '1.5';
document.body.appendChild(tempDiv);
// Use html2canvas to capture the content
html2canvas(tempDiv, {
scale: 2,
useCORS: true,
allowTaint: true
}).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const imgWidth = 190; // A4 width in mm
const pageHeight = 297; // A4 height in mm
const imgHeight = canvas.height * imgWidth / canvas.width;
let heightLeft = imgHeight;
let position = 10;
// Add first page
pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
// Add additional pages if needed
while (heightLeft >= 0) {
position = heightLeft - imgHeight;
pdf.addPage();
pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
}
// Add page numbers if selected
if (pageNumbers) {
const pageCount = pdf.internal.getNumberOfPages();
for (let i = 1; i <= pageCount; i++) {
pdf.setPage(i);
pdf.setFontSize(10);
pdf.text(`Page ${i} of ${pageCount}`, pdf.internal.pageSize.width - 40, pdf.internal.pageSize.height - 10);
}
}
// Save PDF
pdf.save('document.pdf');
showNotification('Document exported as PDF', 'success');
// Remove temporary div
document.body.removeChild(tempDiv);
}).catch(error => {
console.error('Error exporting PDF:', error);
showNotification('Error exporting PDF', 'error');
// Remove temporary div
if (document.body.contains(tempDiv)) {
document.body.removeChild(tempDiv);
}
});
}
function exportAsMarkdown() {
const content = editor.innerHTML;
let markdown = content;
// Convert HTML to Markdown (simplified)
markdown = markdown.replace(/]*>(.*?)<\/h1>/gi, '# $1');
markdown = markdown.replace(/]*>(.*?)<\/h2>/gi, '## $1');
markdown = markdown.replace(/]*>(.*?)<\/h3>/gi, '### $1');
markdown = markdown.replace(/]*>(.*?)<\/h4>/gi, '#### $1');
markdown = markdown.replace(/]*>(.*?)<\/h5>/gi, '##### $1');
markdown = markdown.replace(/]*>(.*?)<\/h6>/gi, '###### $1');
markdown = markdown.replace(/]*>(.*?)<\/strong>/gi, '**$1**');
markdown = markdown.replace(/]*>(.*?)<\/b>/gi, '**$1**');
markdown = markdown.replace(/]*>(.*?)<\/em>/gi, '*$1*');
markdown = markdown.replace(/]*>(.*?)<\/i>/gi, '*$1*');
markdown = markdown.replace(/]*>(.*?)<\/u>/gi, '$1');
markdown = markdown.replace(/]*>(.*?)<\/del>/gi, '~~$1~~');
markdown = markdown.replace(/]*>(.*?)<\/strike>/gi, '~~$1~~');
markdown = markdown.replace(/]*href="(.*?)"[^>]*>(.*?)<\/a>/gi, '[$2]($1)');
markdown = markdown.replace(/
]*src="(.*?)"[^>]*alt="(.*?)"[^>]*>/gi, '');
markdown = markdown.replace(/]*>(.*?)<\/blockquote>/gi, '> $1');
markdown = markdown.replace(/]*>(.*?)<\/code>/gi, '`$1`');
markdown = markdown.replace(/]*>(.*?)<\/pre>/gi, '```\n$1\n```');
markdown = markdown.replace(/
]*>(.*?)<\/ul>/gis, function(match, content) {
return content.replace(/- ]*>(.*?)<\/li>/gi, '- $1') + '\n';
});
markdown = markdown.replace(/
]*>(.*?)<\/ol>/gis, function(match, content) {
let index = 1;
return content.replace(/- ]*>(.*?)<\/li>/gi, function() {
return index++ + '. $1';
}) + '\n';
});
markdown = markdown.replace(/
]*>/gi, '\n');
markdown = markdown.replace(/]*>(.*?)<\/p>/gi, '$1\n\n');
markdown = markdown.replace(/
]*>(.*?)<\/div>/gi, '$1\n');
markdown = markdown.replace(/]*>(.*?)<\/span>/gi, '$1');
markdown = markdown.replace(/ /gi, ' ');
markdown = markdown.replace(/</gi, '<');
markdown = markdown.replace(/>/gi, '>');
markdown = markdown.replace(/&/gi, '&');
// Clean up extra whitespace
markdown = markdown.replace(/\n{3,}/g, '\n\n');
const blob = new Blob([markdown], { type: 'text/markdown' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.md';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as Markdown', 'success');
}
function exportAsJSON() {
const content = editor.innerHTML;
const data = {
title: 'Document',
content: content,
created: new Date().toISOString(),
modified: new Date().toISOString()
};
const json = JSON.stringify(data, null, 2);
const blob = new Blob([json], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.json';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as JSON', 'success');
}
function exportAsXML() {
const content = editor.innerHTML;
const xml = `
Document
${new Date().toISOString()}
${new Date().toISOString()}
`;
const blob = new Blob([xml], { type: 'application/xml' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.xml';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as XML', 'success');
}
function exportAsRTF() {
const content = editor.innerHTML;
// Simplified RTF export
const rtf = `{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}
\f0\fs24
${content.replace(/<[^>]*>/g, '')}
}`;
const blob = new Blob([rtf], { type: 'application/rtf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.rtf';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as RTF', 'success');
}
function exportAsCSV() {
const content = editor.innerText || editor.textContent || '';
const lines = content.split('\n');
let csv = '';
lines.forEach(line => {
const cells = line.split('\t');
csv += cells.map(cell => `"${cell.replace(/"/g, '""')}"`).join(',') + '\n';
});
const blob = new Blob([csv], { type: 'text/csv' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.csv';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as CSV', 'success');
}
]*>(.*?)<\/h3>/gi, '### $1');
markdown = markdown.replace(/]*>(.*?)<\/h4>/gi, '#### $1');
markdown = markdown.replace(/]*>(.*?)<\/h5>/gi, '##### $1');
markdown = markdown.replace(/]*>(.*?)<\/h6>/gi, '###### $1');
markdown = markdown.replace(/]*>(.*?)<\/strong>/gi, '**$1**');
markdown = markdown.replace(/]*>(.*?)<\/b>/gi, '**$1**');
markdown = markdown.replace(/]*>(.*?)<\/em>/gi, '*$1*');
markdown = markdown.replace(/]*>(.*?)<\/i>/gi, '*$1*');
markdown = markdown.replace(/]*>(.*?)<\/u>/gi, '$1');
markdown = markdown.replace(/]*>(.*?)<\/del>/gi, '~~$1~~');
markdown = markdown.replace(/]*>(.*?)<\/strike>/gi, '~~$1~~');
markdown = markdown.replace(/]*href="(.*?)"[^>]*>(.*?)<\/a>/gi, '[$2]($1)');
markdown = markdown.replace(/
]*src="(.*?)"[^>]*alt="(.*?)"[^>]*>/gi, '');
markdown = markdown.replace(/]*>(.*?)<\/blockquote>/gi, '> $1');
markdown = markdown.replace(/]*>(.*?)<\/code>/gi, '`$1`');
markdown = markdown.replace(/]*>(.*?)<\/pre>/gi, '```\n$1\n```');
markdown = markdown.replace(/
]*>(.*?)<\/ul>/gis, function(match, content) {
return content.replace(/- ]*>(.*?)<\/li>/gi, '- $1') + '\n';
});
markdown = markdown.replace(/
]*>(.*?)<\/ol>/gis, function(match, content) {
let index = 1;
return content.replace(/- ]*>(.*?)<\/li>/gi, function() {
return index++ + '. $1';
}) + '\n';
});
markdown = markdown.replace(/
]*>/gi, '\n');
markdown = markdown.replace(/]*>(.*?)<\/p>/gi, '$1\n\n');
markdown = markdown.replace(/
]*>(.*?)<\/div>/gi, '$1\n');
markdown = markdown.replace(/]*>(.*?)<\/span>/gi, '$1');
markdown = markdown.replace(/ /gi, ' ');
markdown = markdown.replace(/</gi, '<');
markdown = markdown.replace(/>/gi, '>');
markdown = markdown.replace(/&/gi, '&');
// Clean up extra whitespace
markdown = markdown.replace(/\n{3,}/g, '\n\n');
const blob = new Blob([markdown], { type: 'text/markdown' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.md';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as Markdown', 'success');
}
function exportAsJSON() {
const content = editor.innerHTML;
const data = {
title: 'Document',
content: content,
created: new Date().toISOString(),
modified: new Date().toISOString()
};
const json = JSON.stringify(data, null, 2);
const blob = new Blob([json], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.json';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as JSON', 'success');
}
function exportAsXML() {
const content = editor.innerHTML;
const xml = `
Document
${new Date().toISOString()}
${new Date().toISOString()}
`;
const blob = new Blob([xml], { type: 'application/xml' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.xml';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as XML', 'success');
}
function exportAsRTF() {
const content = editor.innerHTML;
// Simplified RTF export
const rtf = `{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}
\f0\fs24
${content.replace(/<[^>]*>/g, '')}
}`;
const blob = new Blob([rtf], { type: 'application/rtf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.rtf';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as RTF', 'success');
}
function exportAsCSV() {
const content = editor.innerText || editor.textContent || '';
const lines = content.split('\n');
let csv = '';
lines.forEach(line => {
const cells = line.split('\t');
csv += cells.map(cell => `"${cell.replace(/"/g, '""')}"`).join(',') + '\n';
});
const blob = new Blob([csv], { type: 'text/csv' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.csv';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as CSV', 'success');
}
]*>(.*?)<\/h5>/gi, '##### $1');
markdown = markdown.replace(/]*>(.*?)<\/h6>/gi, '###### $1');
markdown = markdown.replace(/]*>(.*?)<\/strong>/gi, '**$1**');
markdown = markdown.replace(/]*>(.*?)<\/b>/gi, '**$1**');
markdown = markdown.replace(/]*>(.*?)<\/em>/gi, '*$1*');
markdown = markdown.replace(/]*>(.*?)<\/i>/gi, '*$1*');
markdown = markdown.replace(/]*>(.*?)<\/u>/gi, '$1');
markdown = markdown.replace(/]*>(.*?)<\/del>/gi, '~~$1~~');
markdown = markdown.replace(/]*>(.*?)<\/strike>/gi, '~~$1~~');
markdown = markdown.replace(/]*href="(.*?)"[^>]*>(.*?)<\/a>/gi, '[$2]($1)');
markdown = markdown.replace(/
]*src="(.*?)"[^>]*alt="(.*?)"[^>]*>/gi, '');
markdown = markdown.replace(/]*>(.*?)<\/blockquote>/gi, '> $1');
markdown = markdown.replace(/]*>(.*?)<\/code>/gi, '`$1`');
markdown = markdown.replace(/]*>(.*?)<\/pre>/gi, '```\n$1\n```');
markdown = markdown.replace(/
]*>(.*?)<\/ul>/gis, function(match, content) {
return content.replace(/- ]*>(.*?)<\/li>/gi, '- $1') + '\n';
});
markdown = markdown.replace(/
]*>(.*?)<\/ol>/gis, function(match, content) {
let index = 1;
return content.replace(/- ]*>(.*?)<\/li>/gi, function() {
return index++ + '. $1';
}) + '\n';
});
markdown = markdown.replace(/
]*>/gi, '\n');
markdown = markdown.replace(/]*>(.*?)<\/p>/gi, '$1\n\n');
markdown = markdown.replace(/
]*>(.*?)<\/div>/gi, '$1\n');
markdown = markdown.replace(/]*>(.*?)<\/span>/gi, '$1');
markdown = markdown.replace(/ /gi, ' ');
markdown = markdown.replace(/</gi, '<');
markdown = markdown.replace(/>/gi, '>');
markdown = markdown.replace(/&/gi, '&');
// Clean up extra whitespace
markdown = markdown.replace(/\n{3,}/g, '\n\n');
const blob = new Blob([markdown], { type: 'text/markdown' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.md';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as Markdown', 'success');
}
function exportAsJSON() {
const content = editor.innerHTML;
const data = {
title: 'Document',
content: content,
created: new Date().toISOString(),
modified: new Date().toISOString()
};
const json = JSON.stringify(data, null, 2);
const blob = new Blob([json], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.json';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as JSON', 'success');
}
function exportAsXML() {
const content = editor.innerHTML;
const xml = `
Document
${new Date().toISOString()}
${new Date().toISOString()}
`;
const blob = new Blob([xml], { type: 'application/xml' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.xml';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as XML', 'success');
}
function exportAsRTF() {
const content = editor.innerHTML;
// Simplified RTF export
const rtf = `{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}
\f0\fs24
${content.replace(/<[^>]*>/g, '')}
}`;
const blob = new Blob([rtf], { type: 'application/rtf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.rtf';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as RTF', 'success');
}
function exportAsCSV() {
const content = editor.innerText || editor.textContent || '';
const lines = content.split('\n');
let csv = '';
lines.forEach(line => {
const cells = line.split('\t');
csv += cells.map(cell => `"${cell.replace(/"/g, '""')}"`).join(',') + '\n';
});
const blob = new Blob([csv], { type: 'text/csv' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.csv';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as CSV', 'success');
}
]*>(.*?)<\/blockquote>/gi, '> $1');
markdown = markdown.replace(/]*>(.*?)<\/code>/gi, '`$1`');
markdown = markdown.replace(/]*>(.*?)<\/pre>/gi, '```\n$1\n```');
markdown = markdown.replace(/
]*>(.*?)<\/ul>/gis, function(match, content) {
return content.replace(/- ]*>(.*?)<\/li>/gi, '- $1') + '\n';
});
markdown = markdown.replace(/
]*>(.*?)<\/ol>/gis, function(match, content) {
let index = 1;
return content.replace(/- ]*>(.*?)<\/li>/gi, function() {
return index++ + '. $1';
}) + '\n';
});
markdown = markdown.replace(/
]*>/gi, '\n');
markdown = markdown.replace(/]*>(.*?)<\/p>/gi, '$1\n\n');
markdown = markdown.replace(/
]*>(.*?)<\/div>/gi, '$1\n');
markdown = markdown.replace(/]*>(.*?)<\/span>/gi, '$1');
markdown = markdown.replace(/ /gi, ' ');
markdown = markdown.replace(/</gi, '<');
markdown = markdown.replace(/>/gi, '>');
markdown = markdown.replace(/&/gi, '&');
// Clean up extra whitespace
markdown = markdown.replace(/\n{3,}/g, '\n\n');
const blob = new Blob([markdown], { type: 'text/markdown' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.md';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as Markdown', 'success');
}
function exportAsJSON() {
const content = editor.innerHTML;
const data = {
title: 'Document',
content: content,
created: new Date().toISOString(),
modified: new Date().toISOString()
};
const json = JSON.stringify(data, null, 2);
const blob = new Blob([json], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.json';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as JSON', 'success');
}
function exportAsXML() {
const content = editor.innerHTML;
const xml = `
Document
${new Date().toISOString()}
${new Date().toISOString()}
`;
const blob = new Blob([xml], { type: 'application/xml' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.xml';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as XML', 'success');
}
function exportAsRTF() {
const content = editor.innerHTML;
// Simplified RTF export
const rtf = `{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}
\f0\fs24
${content.replace(/<[^>]*>/g, '')}
}`;
const blob = new Blob([rtf], { type: 'application/rtf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.rtf';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as RTF', 'success');
}
function exportAsCSV() {
const content = editor.innerText || editor.textContent || '';
const lines = content.split('\n');
let csv = '';
lines.forEach(line => {
const cells = line.split('\t');
csv += cells.map(cell => `"${cell.replace(/"/g, '""')}"`).join(',') + '\n';
});
const blob = new Blob([csv], { type: 'text/csv' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.csv';
a.click();
URL.revokeObjectURL(url);
showNotification('Document exported as CSV', 'success');
}
