Vue
this.editor.config.onchange = (html) => {
var reg = /(?<=img src=").*?(?=" alt=)/g
var str = html.match(reg)
this.old = this.new;
this.new = str?str:[];
if( this.old.length > this.new.length ){
for(let index in this.old){
if( this.$utils.isInArray(this.new,this.old[index]) == false ){
let imgName = this.old[index].split("\\").slice(-1)
this.$api.get("deleteImg?fileName=" + imgName)
}
}
}
}
Utils
function isInArray(arr,value){
for(var i = 0; i < arr.length; i++){
if(value === arr[i]){
return true;
}
}
return false;
}
|