修复图片上传断网后重传不显示HTML标签

This commit is contained in:
Ember 2024-07-02 20:20:18 +08:00
parent 15d33fd759
commit 4755543d0e

View File

@ -634,29 +634,30 @@ markdown 基本语法教程 空格与换行 markdown 语法对于空格与换行
} catch (error) { } catch (error) {
console.error("图片上传失败:", error); console.error("图片上传失败:", error);
alert("图片上传失败!"); alert("图片上传失败!");
event.target.value = '';
} }
} }
// 复制HTML标签到剪贴板 // 复制HTML标签到剪贴板
function copyImageUrl() { function copyImageUrl() {
const imageTag = document.getElementById("imageUrl").innerText; const imageTag = document.getElementById("imageUrl").innerText;
// 创建一个临时文本区域元素 // 创建一个临时文本区域元素
const textArea = document.createElement("textarea"); const textArea = document.createElement("textarea");
textArea.value = imageTag; textArea.value = imageTag;
document.body.appendChild(textArea); document.body.appendChild(textArea);
textArea.select(); textArea.select();
try { try {
const successful = document.execCommand('copy'); const successful = document.execCommand('copy');
const msg = successful ? '标签已复制到剪贴板!请直接粘贴到 markdown 编辑区中,并根据预览效果调整大小。' : '复制失败!'; const msg = successful ? '标签已复制到剪贴板!请直接粘贴到 markdown 编辑区中,并根据预览效果调整大小。' : '复制失败!';
alert(msg); alert(msg);
} catch (err) { } catch (err) {
alert("复制失败!", err); alert("复制失败!", err);
}
document.body.removeChild(textArea);
} }
document.body.removeChild(textArea);
}
document.getElementById('SubmitButton').onclick = function() { document.getElementById('SubmitButton').onclick = function() {