2012-09-19 2 views
1

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 
      }); 
     } 
    } 

답변

0

하는이 시도, 나를 위해 작동합니다

onUploaded: function(a) { this.removePane(); var c = a.url; if (this.im) { this.im || (this.ne.selectedInstance.restoreRng(), this.ne.nicCommand("insertImage", c), this.im = this.findElm("IMG", "src", c)); var b = parseInt(this.ne.selectedInstance.elm.getStyle("width")); this.im && this.im.setAttributes({ src: c, width: b && a.width ? Math.min(b, a.width) : "", alt: a.alt }) } else { this.ln || (this.ne.selectedInstance.restoreRng(), this.ne.nicCommand("createlink", c), this.ln = this.findElm('A', 'href', c)); this.ln && this.ln.setAttributes({ href: c, title: 'PDF' }); } }