My functionality is Before selection start i want to insert one symbol & after selection end also want to insert one symbol. for that purpose i want the exact position of selection start & selection end.
Thanks,
Atul Deshmukh
1 Answer, 1 is accepted
0
Tervel
Telerik team
answered on 07 Aug 2009, 07:39 AM
Hello Atul,
There are two ways you can do that. One is by dealing directly with the low-level brower API - e.g. deal with TextRanges, the other is by using the editor's API.
1. Using TextRange.
The TextRange object is implemented in completely different manner in IE and FF. You can read more information about it online, such as on MSDN .
You can obtain a (browser-dependent) range from the editor by calling the following client-side code:
var range = editor.getSelection().getRange();
2. Using the editor API
If the case you describe is as simple as adding a symbol before and after the selection, you can do the following:
var html = editor.getSelectionHtml();
editor.pasteHtml("~" + html + "~");