我正在开发一个nicEdit插件来上传图片以外的文件。为此,我使用了 nicUpload 插件并正在对其进行调整。
正如您在下面的代码中看到的那样,我首先插入了一个图像,然后我尝试将该图像包装在一个链接中,但它不起作用。
如果我删除该//Insert the image
部分,我可以换行所选文本,但我想创建图像,然后选择该图像作为要换行的文本。
当该部分存在时,该//Insert the link
部分根本不工作。//Insert the image
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
});
}
}