QUESTION: Insert tags around highlighted text

While it's going to be a little bit of overkill you can check out our
Textile Editor Helper plugin to learn how to do what you're asking.
The javascript is pretty simple and straightforward.

http://slateinfo.blogs.wvu.edu/plugins/textile_editor_helper