Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pdf2htmlEX support #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add pdf2htmlEX support #1

wants to merge 1 commit into from

Conversation

jwgmeligmeyling
Copy link
Member

@jwgmeligmeyling jwgmeligmeyling commented May 12, 2024

Summary

A start with pdf2htmlEX support for Hypothes.is

Screenshots

Collapsed

localhost_3000_document_pdf2htmlex2(Laptop)

Side-by-side

localhost_3000_document_pdf2htmlex2(Laptop) (1)

@@ -15,6 +16,10 @@ export function createIntegration(annotator: Annotator): Integration {
return new PDFIntegration(annotator);
}

if (isPdf2htmlEX()) {
Copy link
Member Author

@jwgmeligmeyling jwgmeligmeyling May 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I would pass an integration through the hypothesis config object, but this how its currently done for the existing PDF.js integration 🤷🏻‍♂️


let page = this._pdfViewer.pages.find(page => {
let xpath = xpathFromNode(page.page, root);
return range?.startContainer.startsWith(xpath)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find a better way than an xpath prefix comparison to find the page.

It also means that we're basically only relying on RangeSelector whereas the other selectors are deemed more performant or robust. Luckily, the DOM of the pdf2HtmlEx output is stable.

@jwgmeligmeyling jwgmeligmeyling force-pushed the pdf2htmlex branch 6 times, most recently from bdba276 to ea9d000 Compare May 12, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant