2017-09-14 83 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回調順序中的設置得到的文件內容。