tinymce.PluginManager.add('gallery', function(editor, url) { // 注册一个工具栏按钮名称 editor.ui.registry.addButton('gallery', { text: '素材库', onAction: function (e) { $Gallery.GalleryDialogOpen({max:10,size:100,is_new:1,suffix:'bmp,gif,jpg,jpeg,png',type:'1', tabs:true,multiple:true,callback:function (res) { console.log(res.length); if(res.length > 1){ $.each(res, function (key, val) { if(parseInt(val.type) === 1){ var html='

'+val.original+'

'; editor.insertContent(html); } else { tinyMCE.activeEditor.setContent( `

` ); } }) } else { if(parseInt(res.type) === 1){ var html='

'+res.original+'

'; editor.insertContent(html); } else { tinyMCE.activeEditor.setContent( `

` ); } } }}); } }); return { getMetadata: function () { return { //插件名和链接会显示在“帮助”→“插件”→“已安装的插件”中 name: "gallery",//插件名称 url: "http://exampleplugindocsurl.com", //作者网址 }; } }; });