. execCommand 'insertHTML' , . :
selection = window.getSelection().toString();
wrappedselection = '<span class="accent" style="somestyle">' + selection + '</span>';
document.execCommand('insertHTML', false, wrappedselection);
, , <b>, <i> intext-html- - - ( to post):
selection = window.getSelection().getRangeAt(0).cloneContents();
span = document.createElement('span');
span.appendChild(selection);
wrappedselection = '<span class="accent1">'+span.innerHTML+'</span>';
document.execCommand('insertHTML', false, wrappedselection);
HTML IE. https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand