ここにある質問に従って、tinymce にカスタム ドロップダウンを追加しましたが、機能しません。tinyMCE.init に関連するコードを追加し、プラグインを登録すると、コンソールに次のエラーが表示されます。
キャッチされていない TypeError: オブジェクト [オブジェクト オブジェクト] にメソッド 'addMenuItem' がありません
私の目的は、選択するとコンテンツがテキストエリアに挿入されるドロップダウンを持つことです。今はボタンを使ってやっているのですが、どんどん積み重なってごちゃごちゃしています。場所に散らばるボタンが多すぎずに簡単に追加できるように、ドロップダウンを使用することをお勧めします。
関連ファイルをヘッダーに含めたと確信していますが、おそらくそれがエラーの原因でしょうか?
私のコードは以下にあります
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'
});
どんな助けでも大歓迎です!