An iframes document can be simplified using:
var doc = tinymce.get('comment').getDoc();
EDIT: To achieve what you want, you can catch the click event inside tinymce and do what you want. You need to paste this code into your own tinymce plugin or use the tinymce initialization parameter:
ed.onClick.add(function(ed, evt){
if (evt.explicitOriginalTarget){
if (evt.explicitOriginalTarget.nodeName.toLowerCase() == 'img'){
console.log(evt.explicitOriginalTarget);
alert('image clicked');
}
}
else if (evt.target) {
if (evt.target.nodeName.toLowerCase() == 'img'){
console.log(evt.target);
alert('image clicked');
}
}
});
source
share