I try to see if the TinyMCE inline editor is currently visible or the text is selected.
Solved.
Christoffer guided me to the right thing:
<script>
tinymce.init({
selector:"textarea",
setup: function(editor) {
editor.on('focus', function() {
console.log('focus');
});
editor.on('blur', function(){
console.log('blur');
})
}
});
</script>
More here: Why TinyMCE get focus and blur event, when user jump from other input field?
You can get current selection from the active editor with:
tinyMCE.activeEditor.selection.getContent();
You can also loop all editors with something like:
for (edId in tinymce.editors) {
if (tinymce.editors[edId].isDirty()) {
// do stuff
}
}
For more advanced control over when and if an editor is active you can setup callbacks to the init/focus and blur events in your editor init.