What is the simplest way to toggle the state of a toolbar button (like it works with the default bold-button)? I can\'t \"get\" to that class i Tinymce that changes the butt
In TinyMCE 4 you can use the simpler stateSelector setting:
editor.addButton('SomeButton', {
text: 'My button',
stateSelector: '.class-of-node' // or use an element (an id would probably work as well, but I haven't tried it myself)
});
Or you can use custom logic using the "nodechange" event
editor.addButton('SomeButton', {
text: 'My button',
onPostRender: function() {
var ctrl = this;
ed.on('NodeChange', function(e) {
ctrl.active(e.element.nodeName == 'A');
});
}
});
Reference: https://www.tinymce.com/docs/advanced/migration-guide-from-3.x/#controlstates