Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate dynamically SPAN id's using rangy highlighter module #453

Open
khayati114 opened this issue Aug 28, 2018 · 2 comments
Open

Generate dynamically SPAN id's using rangy highlighter module #453

khayati114 opened this issue Aug 28, 2018 · 2 comments

Comments

@khayati114
Copy link

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

@farhaansari
Copy link

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

@dmytro-feld
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants