【问题标题】:Custom drop down menu - Tinymce自定义下拉菜单 - Tinymce
【发布时间】:2013-11-01 12:40:46
【问题描述】:

我按照位于here 的问题向我的tinymce 添加了一个自定义下拉列表,但我无法让它工作。当我在 tinyMCE.init 周围添加相关代码并注册插件时,我在控制台中收到以下错误

Uncaught TypeError: Object [object Object] has no method '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'    
  });

任何帮助将不胜感激!

【问题讨论】:

    标签: javascript tinymce wysiwyg


    【解决方案1】:

    我更新了我的 TinyMCE 并按照 TinyMCE 网站上的说明进行操作,效果很好

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-11
      • 2012-10-12
      • 2021-08-22
      • 2018-11-30
      • 2011-02-06
      • 2018-04-17
      相关资源
      最近更新 更多