Using a selection / key command based WYSIWYG editor. Works great EXCEPT...
With all the other key commands, it toggles the specific style I, strike, etc on and off.
With the execCommand('bold'), it doesn't unbold the text. It's very frustrating. It's the same for every browser.
Here's the code.
$('body').on('keydown', '.element_content, .element_content_subhead', function(e) {
if(e.ctrlKey){
//bold -- key 'B'
if(e.which == 66){
$sel = $.trim(document.getSelection().toString());
if($sel == ''){
alert('Please select some text to bold');
}
else{
document.execCommand('bold', false, null);
}
}
}
});