plugin.min.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. tinymce.PluginManager.add('axupimgs', function(editor, url) {
  2. var pluginName='多图片上传';
  3. window.axupimgs={}; //扔外部公共变量,也可以扔一个自定义的位置
  4. var baseURL=tinymce.baseURL;
  5. var iframe1 = baseURL+'/plugins/axupimgs/upfiles.html';
  6. axupimgs.images_upload_handler = editor.getParam('images_upload_handler', undefined, 'function');
  7. axupimgs.images_upload_base_path = editor.getParam('images_upload_base_path', '', 'string');
  8. axupimgs.axupimgs_filetype = editor.getParam('axupimgs_filetype', '.png,.gif,.jpg,.jpeg', 'string');
  9. axupimgs.res=[];
  10. var openDialog = function() {
  11. return editor.windowManager.openUrl({
  12. title: pluginName,
  13. size: 'large',
  14. url:iframe1,
  15. buttons: [
  16. {
  17. type: 'cancel',
  18. text: 'Close'
  19. },
  20. {
  21. type: 'custom',
  22. text: 'Save',
  23. name: 'save',
  24. primary: true
  25. },
  26. ],
  27. onAction: function (api, details) {
  28. switch (details.name) {
  29. case 'save':
  30. var html = '';
  31. var imgs = axupimgs.res;
  32. var len = imgs.length;
  33. for(let i=0;i<len;i++){
  34. if( imgs[i].url ){
  35. html += '<img src="'+imgs[i].url+'" />';
  36. }
  37. }
  38. editor.insertContent(html);
  39. axupimgs.res=[];
  40. api.close();
  41. break;
  42. default:
  43. break;
  44. }
  45. }
  46. });
  47. };
  48. editor.ui.registry.getAll().icons.axupimgs || editor.ui.registry.addIcon('axupimgs','<svg viewBox="0 0 1280 1024" xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M1126.2,779.8V87.6c0-24-22.6-86.9-83.5-86.9H83.5C14.7,0.7,0,63.7,0,87.7v692c0,36.2,29.2,89.7,83.5,89.7l959.3-1.3c51.7,0,83.5-42.5,83.5-88.3zm-1044,4V86.3h961.6V783.7H82.2v0.1z" fill="#53565A"/><path d="M603,461.6L521.1,366.3,313,629.8,227.2,546.8,102.4,716.8H972.8v-170L768.2,235.2,603.1,461.6zM284.6,358.4a105.4,105.4,0,0,0,73.5-30c19.5-19.1,30.3-45,30.2-71.8,0-56.8-45.9-103-102.4-103-56.6,0-102.4,46.1-102.4,103C183.4,313.5,228,358.4,284.6,358.4z" fill="#9598A0"/><path d="M1197.7,153.6l-0.3,669.3s13.5,113.9-67.4,113.9H153.6c0,24.1,23.9,87.2,83.5,87.2h959.3c58.3,0,83.6-49.5,83.6-89.9V240.8c-0.1-41.8-44.9-87.2-82.3-87.2z" fill="#53565A"/></svg>');
  49. editor.ui.registry.addButton('axupimgs', {
  50. icon: 'axupimgs',
  51. tooltip: pluginName,
  52. onAction: function() {
  53. openDialog();
  54. }
  55. });
  56. editor.ui.registry.addMenuItem('axupimgs', {
  57. icon: 'axupimgs',
  58. text: '图片批量上传...',
  59. onAction: function() {
  60. openDialog();
  61. }
  62. });
  63. return {
  64. getMetadata: function() {
  65. return {
  66. name: pluginName,
  67. url: "http://tinymce.ax-z.cn/more-plugins/axupimgs.php",
  68. };
  69. }
  70. };
  71. });