rangy
rangy copied to clipboard
Generate dynamically SPAN id's using rangy highlighter module
Hi
I am using rangy serialization and highlighter module to select and highlight text on HTML file. Currently I am using below code to highlight the content of HTML file -
applier = rangy.createClassApplier("highlight", { ignoreWhiteSpace : true, tagNames : [ "span", "a" ] applier.applyToSelection(frame.contentWindow);
Now my requirement is to add tooltip on this highlightion.? How can I achieve that ?? One thing I was thinking since I am passing span tag to highlight the content , I can add tooltip on this span element itself. But currently they don't have any unqiue id to identity the content. I need to add id's on these span elements so that i can add tooltip on them .Is it possible to add dynamic id's on these span elements? If so how to achieve the same ??
Hi
For this case, you can add elementsAttributes in the "classApplier" code.
for Ex:
this.highlighter.addClassApplier(rangy.createClassApplier("highlight", { ignoreWhiteSpace: true, tagNames: ["span","a"], elementAttributes " { "id" = "Unique-Id", "onClick" = "onClickHighlight(this);" }));
Hey, unfortunately it's not clear how to apply really unique attribute as we use addClassApplier
on initialization.
Any thoughts? Thx!