这项任务并不容易(也必须努力完成此任务)。您需要在自己的自定义插件之一中设置函数 createControl。我将向您展示我自己的插件之一的一些代码,它应该为您指明正确的方向
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
// Creates a custom listbox
createControl: function(n, cm) {
switch (n) {
// you may define more than one listbox here!
// make sure this string is in your buttonconfig
case 'my_new_listbox':
var listboxIdPart = 'my_new_listbox';
// Listbox erzeugen
var ctrl = cm.createListBox(listboxIdPart, {
title : 'Title',
// v could be 'value1_here' or "value2_here", it isbest to use simple numers as values
//need to specify what shall happen depending on the value
onselect : function(v) {
if (v == 0){
return;
}
else {
// alert('value choosen:' + v)
// your actions here
return;
}
}
}); // closing bracket
// Add entries to the dropdown
ctrl.add('entry1', 'value1_here');
ctrl.add('entry2', 'value2_here');
ctrl.add('entry3', 'value3_here');
// Return new listbox
return ctrl;
}
return null;
},