This is a migrated thread and some comments may be shown as answers.

[Solved] Finding selection start and end position in a RadEditor

1 Answer 146 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Atul
Top achievements
Rank 1
Atul asked on 04 Aug 2009, 08:27 AM
Hello,

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

Sort by
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 + "~");

Best wishes,
Tervel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Atul
Top achievements
Rank 1
Answers by
Tervel
Telerik team
Share this question
or