在tinymce容器中添加type = file的输入元素 [英] Add an input element of type=file in tinymce container
问题描述
我正在尝试扩展tinymce插件,并且需要添加type = file的输入元素.
I am trying to extend a tinymce pluggin and need to add an input element of type=file.
(我是这种练习的新手,请原谅我的无知.也找不到可以使用的示例/示例.)
(I am new to such an exercise so please pardon my ignorance.. Also could not find examples/samples to work with..)
似乎您可以执行以下操作来显示在面板中打开的容器中的元素:
It seems you can do the following to show elements to a container that opens in a panel :
var generalFormItems = [
{name: 'alt', type: 'textbox', label: 'Image description'},
{name: 'width', type: 'textbox', maxLength: 3, size: 3, onchange: recalcSize},
];
win = editor.windowManager.open({
title: 'Insert/edit image',
data: data,
bodyType: 'tabpanel',
body: [
{
title: 'General',
type: 'form',
items: generalFormItems
},
],
onSubmit: onSubmitForm });
我有兴趣添加type = file(<input type="file".../>
)的输入html.因此,应该有通常的html按钮,它将在浏览器上显示文件对话框",以允许用户选择文件.所以我希望这样:
I am interested in adding an input html of type=file (<input type="file".../>
). So there should be the usual html button that will show the 'file dialog' on the browser to allow the user to pick a file. So something like this I am hoping :
var generalFormItems = [
{name: 'alt', type: 'textbox', label: 'Image description'},
{name: 'width', type: 'textbox', maxLength: 3, size: 3, onchange: recalcSize},
---> {name: 'fileSelect', type: 'file', label: 'Select a File to Upload'},
];
有可能这样做吗?
推荐答案
设法弄清楚了这一点,并希望将答案留给其他尝试做类似事情的人.
Managed to figure this out and want to leave the answer here for others trying to do something similar.
每个UI表单元素上都有一个子类型",它将按原样添加到DOM中.因此,执行以下操作对我有用:
There is a 'subtype' on each of the UI form elements that will get added to the DOM as is. So doing the below did the trick for me :
{name: 'file', type: 'textbox', subtype: 'file', label: 'Upload', onchange: uploadFile},
这篇关于在tinymce容器中添加type = file的输入元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!