带有文件输入控件类型的 Tinymce 弹出 window

Tinymce popup window with file input controll type

在我的自定义 tinyme 插件上,我想呈现一个带有 2 个选项卡的 window:

完成这项工作的代码是:

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 呈现的弹出 window 设置文件控制类型?

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 回调才能获取文件内容。