看这里,我认为它足以制作任何类型的带有扩展选项的TinyMCE编辑器按钮,如下拉等
https://www.gavick.com/blog/wordpress-tinymce-custom-buttons
不管怎样,如果我们在弹出窗口中选择下拉菜单、复选框和单选按钮,下面是一个演示。
(function () {
tinymce.PluginManager.add(\'aptmce_btn\', function (editor, url) {
editor.addButton(\'aptmce_btn\', {
text: \'Add popup\',
icon: false,
onclick: function () {
editor.windowManager.open({
title: \'Enter Your PopUp Contents\',
body: [
{
type: \'textbox\',
name: \'textboxName\',
label: \'Title\',
value: \'\'
},
{
type: \'textbox\',
name: \'multilineName\',
label: \'Content\',
value: \'\',
multiline: true,
minWidth: 300,
minHeight: 100
},
{
type: \'listbox\',
name: \'timeformat\',
label: \'Time Format\',
\'values\': [
{text: \'AM\', value: \'am\'},
{text: \'PM\', value: \'pm\'}
]
},
{
type: \'checkbox\',
name: \'blank\',
label: \'Open link in a new tab\'
},
{
type: \'radio\',
name: \'active\',
label: \'Active Something\'
}
],
onsubmit: function (e) {
target = \'\';
if(e.data.blank === true) {
target += \'newtab="on"\';
}
editor.insertContent(\'[show_popup title="\' + e.data.textboxName + \'" content="\' + e.data.multilineName + \'" timeformat="\' + e.data.timeformat + \'" something="\' + e.data.active + \'" \' + target + \' ]\');
}
});
}
});
});
})();
请记住一件事,单选按钮的作用类似于复选框,因为单选按钮尚未完成,请参见此处
https://github.com/tinymce/tinymce/blob/ca0f454b9001b9f20aa26349b25f6d839c1a1146/js/tinymce/skins/lightgray/Radio.less但如果您想要多个单选按钮选项,则可以使用列表框(下拉列表)代替多个单选类型。
希望对你有帮助。