I am trying to do something very basic, I have a textarea and a button, once that button is pressed i want to get the selected text from text and possibly put some other characters around it.

I am creating a basic text editor so i will need to be able to do caret position, selected text etc.
I know I can do javascript interop to do this but I am hoping there is a way to do it without javascript