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

Get the text from a RadEditor

1 Answer 20 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Diego
Top achievements
Rank 1
Diego asked on 04 Oct 2019, 08:44 PM

Hi,

I have a RadEditor and I want to get some text, I get the cursor position with getRange(), but I now need to create a range from the beginning of my text to that position.

Example text:"Hello my world!",

My cursor is after "my|", in the middle of the sentence...

so I want to return "Hello my", excluding "world!".

thanks

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 07 Oct 2019, 06:47 AM

Hi Diego,

RadEditorSelection's client-side API offers getRange() and selectRange() methods to get / restore cursor position. You can review this article. RadEditor utilizes W3C Range and Microsoft TextRange objects and in a more complicated scenario you should use the standard objects. The following articles give more detailed information for the TextRange objects:

http://www.wrox.com/WileyCDA/Section/JavaScript-DOM-Ranges-Page-2.id-292302.html
http://www.quirksmode.org/dom/range_intro.html
http://www.quirksmode.org/js/findpos.html

After creating a text range you will be able to use the following methods: move(), moveStart(), moveEnd() and select().

Regards,
Rumen
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Editor
Asked by
Diego
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or