Webreaper
Webreaper

Reputation: 603

Customising Menu Items doesn't seem to work in TinyMCE v6 or v7

I'm using TinyMCE, but it seems like the documentation here is wrong:

https://www.tiny.cloud/docs/tinymce/7/menus-configuration-options/#example-the-tinymce-default-menu-items

When I modify the visible/available menu items per the documentation, it has no effect on the menu bar. For example, here's a TinyMCE fiddle, that shows the problem:

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  plugins: 'searchreplace',
  menu: {
    edit: { title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall | searchreplace' },
    view: { title: 'View', items: 'code revisionhistory | visualaid visualchars visualblocks | spellchecker | preview fullscreen | showcomments' },
    insert: { title: 'Insert', items: 'image link media addcomment pageembed codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime' },
    format: { title: 'Format', items: 'bold italic underline strikethrough superscript subscript codeformat | styles blocks fontfamily fontsize align lineheight | forecolor backcolor | language | removeformat' },
    tools: { title: 'Tools', items: 'spellchecker spellcheckerlanguage | a11ycheck code wordcount' },
    table: { title: 'Table', items: 'inserttable | cell row column | advtablesort | tableprops deletetable' },
  }
});

https://fiddle.tiny.cloud/3zjoHYUBdO/5

If you run it, you'll see the File Menu still displays.

Is the documentation wrong? Can anyone get this to work? I see the same behaviour whether I do it in plain Javascript, or if I do it in Blazor using a C# defined config option. Seems to happen with TinyMCE 6 or 7.

Upvotes: 0

Views: 109

Answers (2)

Webreaper
Webreaper

Reputation: 603

Okay, looks like the sample in the documentation is a bit misleading. It will always use the default set of menu items, so if you don't want (for example) the File menu, and you want to explicitly specify the menu items in other menus, you need to use a combination of the menu and menubar config items to achieve this. It's doubly confusing as the example in the documentation doesn't include the plugins list of the items actually defined in the menu, meaning that it'll never work as described. Would be good if TinyMCE updated the docs on this.

Working fiddle: https://fiddle.tiny.cloud/3zjoHYUBdO/6

Upvotes: 1

Plamen
Plamen

Reputation: 390

It would be best if you had search and replace plugin. See fiddle.

Upvotes: 0

Related Questions