rangy icon indicating copy to clipboard operation
rangy copied to clipboard

Generate dynamically SPAN id's using rangy highlighter module

Open khayati114 opened this issue 6 years ago • 2 comments

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 ??

khayati114 avatar Aug 28 '18 11:08 khayati114

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);" }));

farhaansari avatar May 14 '19 13:05 farhaansari

Hey, unfortunately it's not clear how to apply really unique attribute as we use addClassApplier on initialization. Any thoughts? Thx!

dmytro-feld avatar Jul 27 '23 10:07 dmytro-feld