readium-shared-js
readium-shared-js copied to clipboard
Problems on get current bookmark data
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.
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>]
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"
)
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()
.
But it is a problem on JS sdk or i need make something different?
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.