画像以外のファイルをアップロードする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
});
}
}