Markdown 编辑器 - 在线工具
← 返回工具列表
Markdown 编辑器
\n';
}
function exportHtml() {
if (!editor.value.trim()) { showMsg('没有可导出的内容', 'error'); return; }
hideMsg();
const fullHtml = buildFullHtml();
const blob = new Blob([fullHtml], { type: 'text/html;charset=utf-8' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'markdown-export.html';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
showMsg('已导出 HTML 文件', 'success');
}
function copyHtml() {
if (!editor.value.trim()) { showMsg('没有可复制的内容', 'error'); return; }
const html = preview.innerHTML;
navigator.clipboard.writeText(html).then(() => {
showMsg('已复制 HTML 到剪贴板', 'success');
}).catch(() => {
const ta = document.createElement('textarea');
ta.value = html;
document.body.appendChild(ta);
ta.select();
document.execCommand('copy');
document.body.removeChild(ta);
showMsg('已复制 HTML 到剪贴板', 'success');
});
}
function clearAll() {
editor.value = '';
hideMsg();
render();
}
render();