Selected text from text Area?

Hi Guys,
I am creating an app like text editor (same as Unity’s question editor where I typed this question), with features bold,italic,underline,font,color,alignment etc.

My problems are-

  • I am unable to get selected text from
  • Unable to get cursor position in Text Area
  • How can I put some characters middle of the text, suppose the text is “EDUATION” and it should be “EDUCATION” so I need to insert “C” after “U” how can I achieve this without deleting “ATION”?
  • How can I make perticular text BOLD by selecting the text and press on bold button(for example see above line in this question where C & U etc are bold)

If you know any plugin to do this so please let me know, I will be very thankful to you.

Thanks!