tinymce.PluginManager.add('axupimgs', function (editor, url) { var pluginName = '多图上传'; window.axupimgs = {}; //扔外部公共变量,也可以扔一个自定义的位置 // var baseURL = tinymce.baseURL; // var baseURL = "http://swt.usuc.f2b211.com:8081" // var iframe1 = baseURL + '/plugins/axupimgs/upfiles.html'; var iframe1 = '../tinymce/axupimgs/upfiles.html'; axupimgs.images_upload_handler = editor.getParam('images_upload_handler', undefined, 'function'); axupimgs.images_upload_base_path = editor.getParam('images_upload_base_path', '', 'string'); axupimgs.axupimgs_filetype = editor.getParam('axupimgs_filetype', '.png,.gif,.jpg,.jpeg', 'string'); axupimgs.res = []; var openDialog = function () { return editor.windowManager.openUrl({ title: pluginName, size: 'large', url: iframe1, buttons: [ { type: 'cancel', text: 'Close' }, { type: 'custom', text: 'Save', name: 'save', primary: true }, ], onAction: function (api, details) { switch (details.name) { case 'save': var html = ''; var imgs = axupimgs.res; var len = imgs.length; for (let i = 0; i < len; i++) { if (imgs[i].url) { html += ''; } } editor.insertContent(html); axupimgs.res = []; api.close(); break; default: break; } } }); }; editor.ui.registry.getAll().icons.axupimgs || editor.ui.registry.addIcon('axupimgs', ''); editor.ui.registry.addButton('axupimgs', { icon: 'axupimgs', tooltip: pluginName, onAction: function () { openDialog(); } }); editor.ui.registry.addMenuItem('axupimgs', { icon: 'axupimgs', text: '图片批量上传...', onAction: function () { openDialog(); } }); return { getMetadata: function () { return { name: pluginName, url: "http://tinymce.ax-z.cn/more-plugins/axupimgs.php", }; } }; });