0
我跟着一個問題位於here添加一個自定義下拉菜單到我的tinymce,但我不能得到它的工作。當我添加相關的代碼在我tinyMCE.init,當我註冊這個插件我碰到下面的錯誤在我的控制檯自定義下拉菜單 - Tinymce
Uncaught TypeError: Object [object Object] has no method 'addMenuItem'
我的目標是有一個下拉菜單選擇時將內容插入textarea的那個。此刻我正在使用按鈕來做這件事,但他們開始堆積起來,看起來非常混亂。我寧願有一個下拉,所以我可以輕鬆地添加到它,而沒有太多的按鈕分散在這個地方。
我確定我已經在我的頭文件中包含了相關文件,但也許這就是錯誤的原因吧?
我的代碼是位於下方
var myListItems = ['Item1','Item2'];
tinymce.PluginManager.add('myNewPluginName', function(editor) {
var menuItems = [];
tinymce.each(myListItems, function(myListItemName) {
menuItems.push({
text: myListItemName,
onclick: function() {
editor.insertContent(myListItemName);
}
});
});
editor.addMenuItem('insertValueOfMyNewDropdown', {
icon: 'date',
text: 'Do something with this new dropdown',
menu: menuItems,
context: 'insert'
});
});
tinyMCE.init({
theme : "advanced",
mode: "exact",
plugins: "table,myNewPluginName",
elements : "elm1,elm2,elm3,elm4,elm5,elm6",
theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
font_size_style_values: "12px,13px,14px,16px,18px,20px",
theme_advanced_toolbar_location : "top",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,"
+ "justifyleft,justifycenter,justifyright,justifyfull,formatselect,"
+ "bullist,numlist,outdent,indent,seperator,fontselect,fontsizeselect",
theme_advanced_buttons2 : "tablecontrols",
height:"500px",
width:"100%",
file_browser_callback : 'myFileBrowser'
});
任何幫助將不勝感激!