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

Examples about highlight data? #392

Open
paulocoutinhox opened this issue May 29, 2017 · 1 comment
Open

Examples about highlight data? #392

paulocoutinhox opened this issue May 29, 2017 · 1 comment

Comments

@paulocoutinhox
Copy link

paulocoutinhox commented May 29, 2017

Hi,

Anyone have examples about highlight data?

1 - Paint all highlight data with selected color?
2 - Detect when user highlight a text to show a custom view?
3 - Detect when user click on a highlighted text to show current options or remove?

As i do on other issues that i ask, i will post my final code here. But i need some way to understand it. I check the reader_view code and all highlight references, but didn't find anything.

Something like this:

img_0729

And this:

img_0730

Thanks.

@danielweck
Copy link
Member

"highlight" plugin code:
https://github.com/readium/readium-shared-js/tree/develop/plugins/highlights

https://github.com/readium/readium-shared-js/blob/develop/plugins/highlights/views/view.js#L7

template: "<div class=\"rd-highlight\"></div>",

https://github.com/readium/readium-shared-js/blob/develop/plugins/highlights/views/border_view.js#L7

template: "<div class=\"rd-highlight-border\"></div>",

https://github.com/readium/readium-shared-js/blob/develop/plugins/highlights/manager.js#L345

    this.getAnnotationsElementSelector = function () {
        return 'div.rd-highlight, div.rd-highlight-border';
    };

Main public API (from which the "manager" instance can be accessed):
https://github.com/readium/readium-shared-js/blob/develop/plugins/highlights/main.js#L42

Example usage from readium-js-viewer:

https://github.com/readium/readium-js-viewer/blob/develop/src/js/EpubReader.js#L851

        $(".icon-annotations").on("click", function () {
            readium.reader.plugins.highlights.addSelectionHighlight(Math.floor((Math.random()*1000000)), "test-highlight");
        });

https://github.com/readium/readium-js-viewer/blob/develop/src/js/EpubReader.js#L1167

readium.reader.plugins.highlights.initialize({
                        annotationCSSUrl: readerOptions.annotationCSSUrl
                    });

                    readium.reader.plugins.highlights.on("annotationClicked", function(type, idref, cfi, id) {
        console.debug("ANNOTATION CLICK: " + id);
                        readium.reader.plugins.highlights.removeHighlight(id);
                    });

Note that annotationCSSUrl references https://github.com/readium/readium-js-viewer/blob/develop/src/css/annotations.css

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

No branches or pull requests

3 participants