[英]Custom drop down menu - Tinymce
I followed a question located here to add a custom dropdown to my tinymce but I cannot get it to work. 我遵循了一个位于此处的问题,将自定义下拉列表添加到我的tinymce,但是我无法使其正常工作。 When I add the relevant code around my tinyMCE.init and when I register the plugin I get the following error in my console
当我在tinyMCE.init周围添加相关代码时,以及在注册插件时,我的控制台中都出现以下错误
Uncaught TypeError: Object [object Object] has no method 'addMenuItem'
未捕获的TypeError:对象[object Object]没有方法'addMenuItem'
My aim is to have a dropdown that when selected will insert content into the textarea. 我的目标是创建一个下拉菜单,当选中该菜单时,它将在文本区域中插入内容。 I am doing this at the moment using buttons, but they are starting to pile up and it looks really messy.
我目前正在使用按钮进行此操作,但是它们开始堆积起来,看起来真的很乱。 I'd much rather prefer to have a dropdown so I can easily add to it without there being too many buttons scattered about the place.
我更希望有一个下拉菜单,这样我就可以轻松地添加到其中,而不会在该位置散布太多按钮。
I am sure I have included the relevant files in my header, but maybe that is the reason for the error perhaps? 我确定我的头文件中已经包含了相关文件,但是也许这就是错误的原因吗?
My code is located below 我的代码位于下面
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'
});
Any help would be greatly appreciated! 任何帮助将不胜感激!
我更新了TinyMCE,并按照TinyMCE网站上的说明进行了操作,效果非常理想
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.