在我的自定义tinyme插件上,我想渲染一个带有2个标签的窗口:
完成这项工作的代码是:
tinymce.PluginManager.add('upload', function(ed, url){
ed.addCommand('initUpload', function(){
//Do stuff
});
//Register a button that open a window
ed.addButton('upload', {
title: 'Upload Files into the editor',
// cmd: 'initUpload',
text: '',
icon:'upload-icon',
onClick: function(){
ed.windowManager.open({
title:'Insert a File',
bodyType:'tabpanel',
body:[
{
title: "From file into your computer",
type:"textbox",//Thing That I need to change with file input
label:"File"
},
{
title: "From Url",
type:"textbox",
label:"Url"
},
],
onsubmit: function(e) {
//do Stuff
}
})
}
});
});
我试图替换:
{
title: "From file into your computer",
type:"textbox",//Thing That I need to change with file input
label:"File"
},
使用:
{
title: "From file into your computer",
type:"file",//Thing That I need to change with file input
label:"File"
},
但出于某种原因,我得到了:
错误:无法按类型找到控件:file
那么如何将文件控件类型设置为可以渲染的弹出窗口?
答案 0 :(得分:2)
如Add an input element of type=file in tinymce container所示,您只需使用将子类型文件放入选项卡配置即可。
换句话说,替换:
{
title: "From file into your computer",
type:"textbox",//Thing That I need to change with file input
label:"File"
},
使用:
{
title: "From file into your computer",
type:"textbox",
subtype:"file"
label:"File"
},
另请注意,您需要提供onchange
回调设置才能获取文件内容。