futurepress / epubjs-reader

Epub.js Reader
MIT License
449 stars 131 forks source link

Get CFI from a specific word #25

Open nux17 opened 5 years ago

nux17 commented 5 years ago

I would like to generate a CFI from a selected word on the epub. I know we can go to a certain place in the epub from a CFI but how get a CFI from "a place" eg. a word?

Thank you.

ZhaoDanyang commented 5 years ago

Maybe you can get a CFI, than try to use the doChapterSearch Method

function doChapterSearch(q) {
    let item = this.book.spine.get(this.rendition.location.start);
    return item.load(book.load.bind(book)).then(item.find.bind(item, q)).finally(item.unload.bind(item));
};