I tried to use window.getSelection().toString(), but it doesn't seem to work. The result is an empty string! What should I use to get the stuff within the document?
window.getSelection().toString()