Question

First: I am not entirely sure of the difference between ranges and selections.

I want to:

  1. Highlight some text

  2. Click on a button and wrap a class around the selected text (I am able to do this using rangy, BUT rangy needs the text to be in a highlighted state, BUT that click removes the highlight on the text.)

Question:

How do i reproduce the highlighted text after that click, so that rangy has something to work with?

Thanks!

Était-ce utile?

La solution

There is an example on the rangy code repository that does exactly what it seems you want.

Have a look at this: http://rangy.googlecode.com/svn/trunk/demos/highlighter.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top