修复下载word中不带图片的问题

This commit is contained in:
何童崇 2022-03-10 15:15:56 +08:00
parent 7d37a565b3
commit 5459f76349
1 changed files with 13 additions and 1 deletions

View File

@ -38,7 +38,19 @@ class ExportWord extends Component {
body: '<body>_body_</body>',
};
const activeDoc = document.getElementById(wordId).cloneNode(true); // 获取 dom 节点
const activeDoc = document.getElementById(wordId); // 获取 dom 节点
if(activeDoc.querySelector(".markdown-body")){
let imgNode =activeDoc.querySelectorAll('.markdown-body img');
if(imgNode.length){
for(const item of imgNode){
let itemSrc=item.getAttribute('src');
if(itemSrc.indexOf('http')===-1){
item.setAttribute('src',location.origin+itemSrc);
}
}
}
}
// 默认样式
const defaultStyle = '.text-div{ text-decoration: underline; margin-right: 15px; } .textarea-div{ text-decoration: underline; } table td,table th{padding: 6px 13px;border: 1px solid #ddd;} table{border-collapse: collapse;}';