简体   繁体   English

TinyMCE-将插件放入下拉列表中? (自定义工具栏菜单按钮)

[英]TinyMCE - put plugins in a dropdown? (Custom Toolbar Menu Button)

I have 4 different plugins for handling images in TinyMCE 4, plus a lot of other plugins. 我在TinyMCE 4中有4个用于处理图像的插件,还有很多其他插件。 I would like to make things a lot more tidy/ clean. 我想使事情整洁/干净。

Is is a way to add existing plugins to a dropdown menu in TinyMCE 4? 是否可以在TinyMCE 4的下拉菜单中添加现有插件?

I know of this method to create dropdowns for new stuff: https://www.tinymce.com/docs/demo/custom-toolbar-menu-button/ 我知道这种为新内容创建下拉列表的方法: https : //www.tinymce.com/docs/demo/custom-toolbar-menu-button/

In the init: 在初始化中:

setup: function(editor) {
    editor.addButton('mybutton', {
      type: 'menubutton',
      text: 'My button',
      icon: false,
      menu: [{
        text: 'Menu item 1',
        onclick: function() {
          editor.insertContent('&nbsp;<strong>Menu item 1 here!</strong>&nbsp;');
        }
      }, {
        text: 'Menu item 2',
        onclick: function() {
          editor.insertContent('&nbsp;<em>Menu item 2 here!</em>&nbsp;');
        }
      }]
    });
  },

BUT I do not understand how to add plugins in there . 但是我不明白如何在其中添加插件 Like the plugin "image" or "link". 就像插件“ image”或“ link”一样。

Anybody knows? 有人知道吗

Each plugin has its own JS file and you will see code in each plugin for how it makes its capabilities available. 每个插件都有其自己的JS文件,您将在每个插件中看到有关如何使其功能可用的代码。 It may add toolbar buttons, complete menus, menu items in existing menus, etc. If you want to change where things appear in the menus/toolbars you will need to modify that code in each plugin. 它可能会添加工具栏按钮,完整菜单,现有菜单中的菜单项等。如果要更改菜单/工具栏中出现的内容,则需要在每个插件中修改该代码。 For example you will find this in the link plugin's code: 例如,您将在link插件的代码中找到此代码:

editor.addButton('link', {
    icon: 'link',
    tooltip: 'Insert/edit link',
    shortcut: 'Meta+K',
    onclick: createLinkList(showDialog),
    stateSelector: 'a[href]'
});

editor.addButton('unlink', {
    icon: 'unlink',
    tooltip: 'Remove link',
    cmd: 'unlink',
    stateSelector: 'a[href]'
});

editor.addShortcut('Meta+K', '', createLinkList(showDialog));
editor.addCommand('mceLink', createLinkList(showDialog));

this.showDialog = showDialog;

editor.addMenuItem('link', {
    icon: 'link',
    text: 'Insert/edit link',
    shortcut: 'Meta+K',
    onclick: createLinkList(showDialog),
    stateSelector: 'a[href]',
    context: 'insert',
    prependToContext: true
});

If you want to change what buttons/menus are added or where they appear you need to modify the relevant code in each plugin file. 如果要更改添加的按钮/菜单或其出现的位置,则需要修改每个插件文件中的相关代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM