This article explains the use of execCommand method used in Javascript that is used to execute a command in JavaScript.
Introduction
if you are going to design a RichTextBox on your own, then go through execCommand method. It will execute a command on the current document or the selected range in the document.
Examples
You can allow the user to paste the text from the clipboard using ‘Paste’ command in the execCommand method.
var myRange1 = document.body.createTextRange();
myRange1.moveToElementText(myDiv2);
myRange1.execCommand('Paste');
After pasting the data, if you want to delete selected data.Then use ‘Delete’ command in the execCommand method
var cRange = document.selection.createRange();
cRange.execCommand('Delete');
If the pasted data is bulletlist and if your want to indent the data then use ‘Indent’ command , if you want to outdent then use ‘Outdent’ command.
var cRange = document.selection.createRange();
cRange.execCommand('Indent');
var cRange = document.selection.createRange();
cRange.execCommand('Outdent');
Conclusion
execCommand will be used to execute the command for the Current Range, Selected document.
Reference
Like this lots of commands can be used in the execute command, you can have a look at this post http://msdn.microsoft.com/en-us/library/ms533049(v=VS.85).aspx
Please download the Zip and execute the HTML. Select the bulletlist and click paste.