I am using Document.execCommand()
to manipulate content of a <div contentEditable = true id="#TextEditor">
.
By clicking a button I can enable bold to my text editor. Code I use to enable bold is <button id="#ApplyBold">B</button>
$('#ApplyBold').click(function () {
$('#TextEditor').focus();
document.execCommand('bold', false, null);
});
Which makes bold enable to the text editor. Similarly I have italic and underline buttons.
Now, how can I detect styles which are enabled by document.execCommand()
command.
For example if I have enabled bold and italic, I need a function say GetAppliedStyles()
which can return applied styles those are enabled by document.execCommand()
command. In this case they are bold and underline.
function GetAppliedStyles()
{
var styles = new Array();
styles = document.execCommand().aCommandName; //which returns list of styles applies
return styles;
}