janpio / ionic-epubjs

Ionic 3 app using Epub.js
https://janpio.github.io/ionic-epubjs/
31 stars 20 forks source link

Implement Search (in chapter) #28

Open janpio opened 6 years ago

janpio commented 6 years ago

Searching in the current chapter could be useful:

book.currentChapter.find("Some Text to look for");

/*
 *  This returns an array of objects like: 
 * [{
 *     "cfi": "epubcfi(/6/18[chap-1]!4/2/30/1:24,1:31)",
 *     "excerpt": "...here is some text to look for..."
 * }, {
 *     "cfi": "epubcfi(/6/18[chap-1]!4/2/66/1:22,1:29)",
 *     "excerpt": "...I have found some more text to look for in this book..."
 * }]
 * 
 * The array can be looped over with a for loop, and used for search results. 
 * This function is case insensitive.
 * Note that this only searches the current chapter.
 * 
 */

https://github.com/futurepress/epub.js/wiki/Tips-and-Tricks#searching-the-current-chapter