mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
Added basic highlighter
This commit is contained in:
parent
eaacf31ca1
commit
e9b37eab2b
6 changed files with 283 additions and 23 deletions
|
@ -749,6 +749,20 @@ Rendition.prototype.replaceAssets = function(section, urls, replacementUrls){
|
|||
|
||||
section.output = replace.substitute(section.output, relUrls, replacementUrls);
|
||||
};
|
||||
|
||||
Rendition.prototype.highlight = function(_cfi, className){
|
||||
var cfi = new EpubCFI(_cfi);
|
||||
var views = this.visible();
|
||||
var found = views.filter(function (view) {
|
||||
if(cfi.spinePos === view.index) return true;
|
||||
});
|
||||
|
||||
// Should only every return 1 item
|
||||
if (found.length) {
|
||||
return found[0].highlight(cfi, className);
|
||||
}
|
||||
};
|
||||
|
||||
//-- Enable binding events to Renderer
|
||||
RSVP.EventTarget.mixin(Rendition.prototype);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue