Friday, November 11, 2011

Working with Selections and Ranges in CKEditor

Working with ranges and selections in CKEditor is almost unbearable. In order to make it a bit easier, i recommend using rangy, a free library that makes the html selection/range api cross-browser-proof. Well, at least it made what i was trying to accomplish cross-browser...


  1. Hi Smith,

    I am facing the same problem. Need to wrap a span around selected text in CKEditor. Need some information about the function you wrote. If I am trying my own plugin then what should be the value of iframe here in the function parameter. and in withNodeFunc we need to create an element... do we need to return anything from the function

  2. I've updated the code-- feel free to take a look

  3. hi there, I am using the ckeditor in drupal, and I don't think it uses iframes, is this possible?

  4. If you're using the version of CKEDITOR that is at, then no. From what i can tell, that is an html textarea on steriods. This code is for CKEDITOR >= 3.5, the "iframe on steroids" version.

    In other words, if you inspect the HTML of your editor and don't see an iframe, this code will not work.

    Thanks for asking!

  5. that is great
    i also faced same issue and on this i have got solution.

    thanks Micah Smith
    Facebook Game Development

  6. Is this code still valid? I'm gettin' some errors while using it (i.e. null iframedoc).