1

I am using TinyMCE4.3.10 (as part of Wordpress 4.5.4). I create a custom tinymce editor using the code:

tinyMCE.execCommand("mceAddEditor", false, captionId);

tinyMCE.execCommand('mceAddControl', false, captionId);

"captionId" points to a textarea. Editor works fine but I want to remove few buttons. How do I do that ? I am not using tinyMCE.init() -- mainly because I don't know if I should be using it and editors works anyway.

I can disable using:

tinyMCE.get(captionId).controlManager.setDisabled('bold', true);

but I want to remove it.

Also, tinyMCE.get(captionId).controlManager.get('bold') returns undefined.

Any help is appreciated.

TimoStaudinger
  • 41,396
  • 16
  • 88
  • 94
rysv
  • 2,416
  • 7
  • 30
  • 48

1 Answers1

2

You use tinymce.init({}) to invoke the editor with specific settings. If the ID of the <textarea> in question is contained in the variable captionId I would do this:

tinymce.init({
  selector: "#" + captionId,  //needs to be a string of the CSS selector for the ID
  .
  . 
  .
});  

This will target only that <textarea> for initialization. If you want to limit what options appear on the toolbar you can do so with the toolbar configuration option:

tinymce.init({
  selector: "#" + captionId,
  toolbar: [
    "table | insertfile undo redo | styleselect | bold italic",
    "removeformat | fontsizeselect | forecolor backcolor"a11ycheck
  ],
  . 
  .
});

https://www.tinymce.com/docs/configure/editor-appearance/#toolbar

Michael Fromin
  • 13,131
  • 2
  • 20
  • 31
  • Thank you so much!! Also I added "link" but not seeing the button for insert/edit link: toolbar: [ "undo redo bold italic link" ] ... Any idea ? – rysv Dec 08 '16 at 18:20
  • In order to use certain toolbar buttons or menu options you need to load some plugins. https://www.tinymce.com/docs/plugins/ For the `link` toolbar button to work you need to load the `link` plugin: https://www.tinymce.com/docs/plugins/link/ – Michael Fromin Dec 08 '16 at 18:56
  • Thanks again! I was able to see the link button - however, the link modal window goes behind my current UI. I can call .focus() but dont have any handle on that window accessible in my code – rysv Dec 09 '16 at 01:35