plugin.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. (function(){
  2. //Section 1 : 按下自定义按钮时执行的代码
  3. var a= {
  4. exec:function(editor){
  5. var ctx=CKEDITOR.context;
  6. if(ctx==null & ctx==undefined)
  7. ctx="";
  8. var features = "dialogHeight:500px; dialogWidth:750px; status:no; scroll:auto; resizable:no; help:no; center:yes;";
  9. var url = jQuery.getContextPath()+ "/manage/file/getFile.ht?type=3";//type =3 为只选图片
  10. if(ctx!=="")
  11. url+="&ctx=" + ctx;
  12. var vReturnValue = window.showModalDialog(url, window,features);
  13. if (typeof (vReturnValue) == 'undefined'||vReturnValue==null) {
  14. vReturnValue = window.retureValue;
  15. }
  16. if (vReturnValue == undefined|| vReturnValue == 'undefined')vReturnValue = "";
  17. if(vReturnValue!=""){
  18. var imgHtml = '<img src= \"' + vReturnValue + '\" >';
  19. editor.insertHtml(imgHtml);
  20. }
  21. }
  22. },
  23. //Section 2 : 创建自定义按钮、绑定方法
  24. b='img';
  25. CKEDITOR.plugins.add(b,{
  26. init:function(editor){
  27. editor.addCommand(b,a);
  28. editor.ui.addButton('img',{
  29. label:'插入图片',
  30. icon: this.path + 'image.gif',
  31. command:b
  32. });
  33. }
  34. });
  35. })();