Charlie Weems
Charlie Weems

Reputation: 1750

How to customize TinyMCE plugin button text?

I'm making use of TinyMCE's template plugin, but I'd like to customize the text that it displays in the menu bar. Currently it defaults to an icon:

tinymce editor icon

What is the correct way of replacing this icon with some text that just says "Use Template"? Approaches I've considered:

  1. Brute force content of the button with JavaScript.
  2. Make my own custom button that launches the template plugin. What's the best way to do this?
  3. Write my own plugin that reproduces the functionality of templates and just replaces the content of the editor.

Unfortunately, hiding templates within the insert menu or using the icon are not an option. Apologies if there's something that I've missed in the docs.

Upvotes: 1

Views: 314

Answers (1)

Charlie Weems
Charlie Weems

Reputation: 1750

I ended up solving this by going through the plugin's source code, and modifying the following line:

editor.addButton('template', {
    title: 'Insert template',
    text: 'Use Template', // Added this attribute
    onclick: createTemplateList(showDialog)
});

To avoid setting up the build process for TinyMCE, I just searched for Insert template in the compiled/minified plugin and then added my text attribute.

Upvotes: 0

Related Questions