Get the text from a RadEditor

2 posts, 0 answers
  1. Diego
    Diego avatar
    1 posts
    Member since:
    Sep 2016

    Posted 04 Oct 2019 Link to this post

    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

  2. Rumen
    Admin
    Rumen avatar
    14213 posts

    Posted 07 Oct 2019 Link to this post

    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.
Back to Top