readium-shared-js icon indicating copy to clipboard operation
readium-shared-js copied to clipboard

Problems on get current bookmark data

Open paulocoutinhox opened this issue 7 years ago • 5 comments

Problems on get current bookmark data

Some epubs are returning null on contentCFI when calling function: "ReadiumSDK.reader.bookmarkCurrentPage()"

The ebook is: https://www.dropbox.com/s/mdoa9w7v3cpqd25/ecologia-urbana.epub?dl=0

To get problem, go to chapter "cidade e não cidade" and try call the function on this page.

paulocoutinhox avatar May 24 '17 13:05 paulocoutinhox

On first page:

["idref": c_d1e8383, "contentCFI": /4/2/2[p0001-01]/2[p0001-01-0]/4,/1:0,/1:1]

On that page:

["idref": c_d1e243, "contentCFI": <null>]

paulocoutinhox avatar May 24 '17 13:05 paulocoutinhox

Mhmm, I am "kinda" able to reproduce this on Safari OSX. Open the web/cloud reader: https://readium.firebaseapp.com ...and drag+drop ecologia-urbana.epub (10MB zipped EPUB container, but loads okay on my computer). Click on the "shared reader bookmark" button in the toolbar (chain link icon), the console reports correct reader.getFirstVisibleCfi() (idref: "c_d1e243", contentCFI: "/4/2/16[p0016-02]/2[p0016-02-1],/1:414,/1:415") but failed reader.getLastVisibleCfi() (idref: "c_d1e243", contentCFI: "/4/NaN/NaN/NaN")

danielweck avatar May 25 '17 14:05 danielweck

So, if I invoke JSON.parse(ReadiumSDK.reader.bookmarkCurrentPage()) in the web browser's console, I get a valid bookmark: idref: "c_d1e243", contentCFI: "/4/2/16[p0016-02]/2[p0016-02-1],/1:414,/1:415". That is because the bookmark is in fact reader.getFirstVisibleCfi().

danielweck avatar May 25 '17 14:05 danielweck

But it is a problem on JS sdk or i need make something different?

paulocoutinhox avatar May 25 '17 15:05 paulocoutinhox

It looks like a bug, but I am not able to pin-point where the CFI "navigation logic" fails. CC @JCCR any ideas? Sometimes reader.getFirstVisibleCfi() fails, sometimes reader.getLastVisibleCfi()... there must be some HTML markup in this EPUB chapter that screws-up the CFI / DOMRange / Client-Rectangles calculations.

danielweck avatar May 25 '17 16:05 danielweck