/** * upfile 1.1v * The tinymce-plugins is used to upfile * * https://github.com/Five-great/tinymce-plugins * * Copyright 2020, Five(Li Hailong) The Chengdu, China https://www.fivecc.cn/ * * Licensed under MIT */ tinymce.PluginManager.add('upfile', function(editor, url) { var pluginName='上传文件'; window.upfile={}; //扔外部公共变量,也可以扔一个自定义的位置 window.upfile.file_callback = editor.getParam('file_callback', undefined, 'function'); window.upfile.tinymce = tinymce; window.upfile.res={}; var openDialog = function() { return editor.windowManager.open({ title: pluginName, body: { type: 'panel', // The root body type - a Panel or TabPanel items: [ // A list of panel components { type: 'iframe', // component type name: 'upfile_iframe', // identifier label: ' ', // text for the iframe's title attribute sandboxed: true, } ] }, initialData: { upfile_iframe: ` upfile
` }, buttons: [ { type: 'cancel', text: 'Close' }, { type: 'custom', text: 'Save', name: 'save', primary: true }, ], onAction: function (api, details) { switch (details.name) { case 'save': var res = upfile.res; var html = ''+res.text+''; editor.insertContent(html); upfile.res={}; api.close(); break; default: break; } } }); }; editor.ui.registry.getAll().icons.upfile || editor.ui.registry.addIcon('upfile',''); editor.ui.registry.addButton('upfile', { icon: 'upfile', tooltip: pluginName, onAction: function() { openDialog() let fv_doc = document.querySelector('iframe[srcdoc]').style.height = '360px'; } }); editor.ui.registry.addMenuItem('upfile', { icon: 'upfileicon', text: '图片上传...', onAction: function() { openDialog() document.querySelector('iframe[srcdoc]').style.height = '360px' } }); return { getMetadata: function() { return { name: pluginName, url: "https://github.com/Five-great/tinymce-plugins", }; } }; });