html Copy code Word Pad
CSS (styles.css): css Copy code body { font-family: Arial, sans-serif; } .toolbar { display: flex; flex-wrap: wrap; border-bottom: 1px solid #ccc; padding: 10px; background-color: #f4f4f4; } .toolbar button, .toolbar select, .toolbar input[type="color"] { margin-right: 5px; padding: 5px; border: 1px solid #ccc; background-color: #fff; cursor: pointer; } #editor { width: 100%; height: calc(100vh - 60px); padding: 10px; box-sizing: border-box; border: none; outline: none; overflow-y: auto; } JavaScript (script.js): javascript Copy code document.getElementById('fontName').addEventListener('change', function() { document.execCommand('fontName', false, this.value); }); document.getElementById('fontSize').addEventListener('change', function() { document.execCommand('fontSize', false, this.value); }); function formatText(command) { document.execCommand(command, false, null); }
banner function changeColor(command, color) { document.execCommand(command, false, color); } function downloadTxtFile() { const element = document.createElement('a'); const editorContent = document.getElementById('editor').innerHTML; const textContent = editorContent.replace(/<[^>]*>/g, ''); const file = new Blob([textContent], { type: 'text/plain' }); element.href = URL.createObjectURL(file); element.download = 'document.txt'; document.body.appendChild(element); element.click(); }