One possible solution that i found, would be to give the toolbar button and the menu item of the custom plugin, unique id of the containing div element:
tinymce.PluginManager.add('simplePlugin', function(editor, url) {
editor.addButton('simplePluginButton', {
id : 'simplePluginButton001',
text: 'Simple Example',
icon: false,
onclick: function() { alert('Do something...'); } });
editor.addMenuItem('simplePluginMenuItem', {
id : 'simplePluginMenuItem001',
text: 'Simple Example',
context: 'tools',
onclick: function() { alert('Do something...'); } });
});
Now the generated HTML code inside the TinyMCE editor looks like this:
<div id="simplePluginButton001"
role="button"
class="mce-widget mce-btn mce-first mce-last"
tabindex="-1"
aria-labelledby="simplePluginButton001">
<button
role="presentation"
type="button"
tabindex="-1">
Simple Example
</button>
</div>
and the div element containers could be retrieved and manipulated directly (for example using jQuery):
var pluginToolbarButton = $("#simplePluginButton001");
pluginToolbarButton.hide();
//pluginToolbarButton.show();
//pluginToolbarButton.remove();
This works just fine for my case - i can build lists of menu item resp. toolbar button id's, that should be made invisible resp. visible.
Nevertheless i wish i could have used the API for such operations - IMO it is more elegant and it seems right.