So im having a little issue with tinymce4 api, iv created a custom format that i want to tigger with a button. However what happens is that when the button is clicked, the style is applied to the button instead of the actual contenteditable field..
tinymce.init({
selector: '#editable',
inline: true,
menubar: false,
toolbar:false,
statusbar: false,
});
setTimeout(function(){
tinymce.activeEditor.formatter.register('mycustomformat', {
inline : 'span',
styles: {color: 'red'}
});
},200);
$('.js-toggleformat').on('click', function(e) {
tinymce.activeEditor.formatter.apply('mycustomformat');
})
and the html:
<button class="js-toggleformat">Toggle</button>
<div id="editable" contenteditable="true"></div>