I need the selected text for specific range say [10, 22], is there a way to get it?
You can use Document#getStringAtRange or Document#getDocumentAtRange:
range = element.editor.getSelectedRange() // [297, 316]
element.editor.getDocument().getStringAtRange(range) // "Different By Design\n"
// equivalent to
element.editor.getDocument().getDocumentAtRange(range).toString() // "Different By Design\n"
A Document always ends with a \n so you may want to trim it off.
Most helpful comment
You can use
Document#getStringAtRangeorDocument#getDocumentAtRange:A
Documentalways ends with a\nso you may want to trim it off.