javascript TinyMCE 自定义“文件”菜单栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16046208/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 03:02:16  来源:igfitidea点击:

TinyMCE customize "file" menubar

javascriptcsstinymce

提问by Kevin Pei

Is there a way to customize (add and remove options, e.t.c..) the menubar in TinyMCE 4.0? I am unable to find any documentation on that specific part of the editor. The image below demonstrates the part I'm talking about. enter image description here

有没有办法在 TinyMCE 4.0 中自定义(添加和删除选项等)菜单栏?我无法找到有关编辑器特定部分的任何文档。下图演示了我正在谈论的部分。在此处输入图片说明

回答by toxalot

Version 4 is a major rewrite and the docs were out of sync for a while.

版本 4 是一个重大的重写,文档有一段时间不同步。

Through experimentation, I discovered that it is possible to enable/disable the drop-downs individually or disable the whole menubar.

通过实验,我发现可以单独启用/禁用下拉菜单或禁用整个菜单栏。

Enable specific drop downs only:

仅启用特定下拉菜单:

tinymce.init({
    selector: "textarea",
    menubar: "edit format"
});

Disable menubar:

禁用菜单栏:

tinymce.init({
    selector: "textarea",
    menubar: false
});

The menubar configuration docshave now been added to TinyMCE site.

菜单栏的配置文档现在已经被添加到TinyMCE的网站。

Also, if you want to completely customize the whole menu, check out the menu configuration docs.

此外,如果您想完全自定义整个菜单,请查看菜单配置文档

回答by alxndr

I ended up customizing both the menu bar and the tool bar by tweaking the menuand toolbarproperties in the settings object passed to tinymce.init():

我最终通过调整传递给的设置对象中的menutoolbar属性来自定义菜单栏和工具栏tinymce.init()

// ...
  menu : {
    edit: { title: 'Edit', items: 'undo redo  | cut copy paste selectall | searchreplace' },
    insert: { title: 'Insert', items: 'link charmap' },
    format: { title: 'Format', items: 'bold italic underline strikethrough superscript subscript | removeformat' },
    table: { title: 'Table', items: 'inserttable tableprops deletetable | cell row column' }
  },
  toolbar: 'undo redo | bold italic underline | link hr | alignleft aligncenter alignright | blockquote bullist numlist outdent indent | code',
// ...

I found the terms for each menu/button by digging around in the source code looking for .addMenuItem(and .addButton(.

我通过在源代码中寻找.addMenuItem(和查找每个菜单/按钮的术语.addButton(

回答by prabhudev mathapati

In TinyMCE 4.xversion, "code" plugin is used to show/edit HTML code of the editor content.

TinyMCE 4.x版本中,“代码”插件用于显示/编辑编辑器内容的 HTML 代码。

To controlthe toolbar, up to 4.0.6 version, theme_advanced_button<1-n>option was used, but above 4.0.6 version, toolbaror toolbar<1-N>option is used.

控制工具栏,到4.0.6版本,theme_advanced_button<1-n>使用的选项,但上述4.0.6版本,toolbar或者toolbar<1-N>选择使用。

By adding "code"plugin to the toolbar options, "Tools"menu will be added with the "Source Code"sub-menu (as button "<>"(icon)).

通过在工具栏选项中添加code插件,“工具”菜单将添加“源代码”子菜单(作为按钮<>(图标))。

tinyMCE.init({
    // ......
    // ......
    plugins: "searchreplace code",

    toolbar1: "separator forecolor backcolor code",
    toolbar2: "<<<some buttons list>>>",
    toolbar3: "<<<some buttons list>>>",
    toolbar4: "<<<some buttons list>>>",
});