Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts

    How to move start and end points of a range?

    Hi all,

    I am trying to wrap a text selection with BBCode. I have it working, but there is one final part I need help with.

    First, here's the code I'm using:
    Code:
        var range = ed.selection.getRng(true);
        var s = ed.dom.create('span', {}, '');
        range.surroundContents(s);
        s.innerHTML = open + s.innerHTML + close;
        ed.selection.select(s);
    This is an explanation of each line:

    1. get the user's selection as a W3C compatible range
    2. create an empty <span> element
    3. surround the selection range with the span
    4. convert the selection from "selection" to "[bbcode]selection[/bbcode]" by using innerHTML
    5. select the new <span> element


    Of course, selecting the span ALSO selects the BBCode open and close tag... like in this picture:



    So, the last thing I need to do (the whole point of this post)... how do I MOVE the range start and end points so that only the selection is selected and NOT the whole thing?

    I will greatly appreciate if someone can tell me how to move those selection start and end points...

    Thanks!

    -- Roger
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #2
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Really? Nobody?
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #3
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    838
    Thanks
    172
    Thanked 90 Times in 90 Posts
    Hi Krupski

    I sent you a pm.

    LT

  • Users who have thanked low tech for this post:

    Krupski (07-05-2011)

  • #4
    Regular Coder
    Join Date
    May 2009
    Posts
    425
    Thanks
    3
    Thanked 62 Times in 61 Posts
    I don't have any experience with this, but have you seen this mini-tutorial? I know it's not what you're trying to do but it might offer some insight or give you an idea that you haven't thought of yet.

    http://the-stickman.com/web-developm...rnet-explorer/

    Hopefully that helps if you haven't seen it yet.
    I'm the founder of Loggur, a place to build and share web apps focused on maximizing efficiency and productivity:
    http://www.loggur.com

    My personal site and blog:
    http://www.tfburgess.com

  • Users who have thanked tfburges for this post:

    Krupski (07-05-2011)

  • #5
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by low tech View Post
    Hi Krupski

    I sent you a pm.

    LT
    Got it thanks!
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #6
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by tfburges View Post
    I don't have any experience with this, but have you seen this mini-tutorial? I know it's not what you're trying to do but it might offer some insight or give you an idea that you haven't thought of yet.

    http://the-stickman.com/web-developm...rnet-explorer/

    Hopefully that helps if you haven't seen it yet.
    Not exactly what I was looking for BUT all the comments in that code help explain a lot... which may just give me enough to figure it all out. Thanks!
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •