我正在開發一個nicEdit插件來上傳圖像以外的文件。爲此,我採用了nicUpload插件,並對其進行了調整。在nicEdit中選擇元素
正如您在下面的代碼中看到的,我首先插入一張圖片,然後嘗試將該圖片封裝在鏈接中,但它不起作用。
如果我刪除了//Insert the image
部分,我可以包裝選定的文本,但我想創建圖像,然後選擇該圖像作爲要包裝的文本。
當//Insert the image
部分存在時,//Insert the link
部分根本不起作用。
onUploaded:function(B){
this.removePane();
// Insert the image.
if(!this.im) {
var tmp = 'javascript:nicImTemp();';
this.ne.nicCommand("insertImage",tmp);
this.im = this.findElm('IMG','src',tmp);
}
if(this.im) {
this.im.setAttributes({
src : 'http://127.0.0.1/nicEditDev/src/nicFile/images/pdf.png',
alt : 'PDF'
});
}
// Insert the link wrapping the image.
console.log(this.im);
var url=B.links.original;
if(!this.ln) {
var tmp = 'javascript:nicTemp();';
this.ne.nicCommand("createlink",tmp);
this.ln = this.findElm('A','href',tmp);
}
if(this.ln) {
this.ln.setAttributes({
href : url,
title : 'PDF',
innerHTML : this.im
});
}
}