2017-09-14 61 views
0

在我的自定义tinyme插件我想呈现一个窗口,其中2个选项卡:与文件输入TinyMCE的弹出窗口CONTROLL键入

  • 一个与URL输入
  • 一个与fuile上传

,没有工作的代码是:

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" 
}, 

但出于某种原因,我得到:

Error: Could not find control by type: file

所以,我怎么能设置一个文件控制研究型到TinyMCE的呈现弹出窗口?

回答

0

如在Add an input element of type=file in tinymce container上看到的,您只需要使用将子类型文件放入您的选项卡fonfiguration。

换句话说更换:

{ 
    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回调顺序中的设置得到的文件内容。