共计 1516 个字符,预计需要花费 4 分钟才能阅读完成。
if(richContent != null){
let index = 0 //width= 第一次呈现的地位
let index2 = 0 // 宽度值结尾下标
let str = ” // 截图 width= 之后的内容
let widths = 0
let img = ”
if(richContent.indexOf(/<img1*>/gi) >= 0){
richContent= richContent.replace(/<img1*>/gi,function(match,capture){
img = JSON.parse(JSON.stringify(match))
index = img.indexOf(‘width=’)
str = img.substring(index+6,img.length)
index2 = str.indexOf(‘”‘,1)
widths=str.substring(1,index2)
if(widths>300){
match = match.replace(/style=”2+”/gi, ”).replace(/style=’3+’/gi, ”);
match = match.replace(/width=”2+”/gi, ”).replace(/width=’3+’/gi, ”);
match = match.replace(/height=”2+”/gi, ”).replace(/height=’3+’/gi, ”);
return match;
}else{
return match;
}
});
if(widths>300){
richContent = richContent.replace(/style=”2+”/gi,function(match,capture){
match = match.replace(/width:4+;/gi, ‘max-width:100%;’).replace(/width:4+;/gi, ‘max-width:100%;’);
return match;
});
richContent = richContent.replace(/<br1*/>/gi, ”);
richContent = richContent.replace(/\<img/gi, ‘<img style=”max-width:100%;margin:0 auto;display:inline-block”‘);
}else{
return match;
}
}
this.richContent = richContent;
}else{
this.richContent = ”
}
- > ↩
- ” ↩
- ‘ ↩
- ; ↩