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

highlighter doesn't use highlighter.doc as default selection when specified #305

Closed
frafra opened this issue Apr 28, 2015 · 2 comments
Closed

Comments

@frafra
Copy link

frafra commented Apr 28, 2015

Hi,
I'm using Firefox 37 x86_64 on Fedora 22 and Rangy 1.3 beta (rev 133c7c6).
highlighter.serialize and removeAllHighlights work as expected even with <iframe> elements, while highlight.highlighSelection doesn't (nothing seems to happen).

Demo (live): https://about.frafra.eu/rangy-iframe-highlighter-bug/
Demo (code): https://github.com/frafra/rangy-iframe-highlighter-bug

@frafra
Copy link
Author

frafra commented May 1, 2015

The problem is caused by the fact that highlightSelection (and other functions) calls api.getSelection() instead of api.getSelection(this.doc). I think that if an highlighter is created on a custom document, this document should be used as default selection.

Workaround (example):

var customSelection = rangy.getSelection(highlighter.doc)};

highlighter.highlightSelection(style, {selection:customSelection});
highlighter.unhighlightSelection(customSelection)
/* etc. */

@frafra frafra changed the title highlighter.highlightSelection doesn't work with <iframe> elements highlighter doesn't use highlighter.doc as default selection when specified May 1, 2015
@timdown
Copy link
Owner

timdown commented May 3, 2015

Thank you, this is very helpful. I've made a fix and it will be in the next release.

@timdown timdown closed this as completed May 3, 2015
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

2 participants