readium / readium-js-viewer

👁 ReadiumJS viewer: default web app for Readium.js library
BSD 3-Clause "New" or "Revised" License
550 stars 186 forks source link

Find all the cfis of a text / word / words provided by the user in epub #639

Open rudra0713 opened 7 years ago

rudra0713 commented 7 years ago

I have created a search box where user can type a text he wishes to find. I want to find all the cfis for that text in my epub document. I already tried this - readium.reader.on("renderer:selected", function(range) { console.log("inside renderer:selected"); var epubcfi = new EPUBJS.EpubCFI(); var cfi = epubcfi.generateCfiFromRangeAnchor(range,book.renderer.currentChapter.cfiBase); console.log("selected:", cfi ); }); I thought this would work when user selects any text in the epub. But this does not work. I searched and found a epub search engine completed by lars vogit. https://github.com/larsvoigt/epub-full-text-search It returns all the cfis when a search query is made with the intended word which is what I need right now. But this is not a readium project and commands like import or require does not seem to work in readium
so I had no way to incorporate this in my project.