esmero / format_strawberryfield

Set of Display formatters, extractors and utils to make Strawberry field data glow
GNU Lesser General Public License v3.0
6 stars 9 forks source link

Replace PDF.JS 2.x with 4.x. && Learn how to use Node Modules (ES6) on web #436

Open DiegoPino opened 3 months ago

DiegoPino commented 3 months ago

What?

I am old(ish) and using .mjs is not as intuitive in a Drupal environment as expected. .mjs are "modules" and are loaded differently. And even if Drupal allows us to do so (with a hidden library property/subproperty) there is nothing that ensure that a module will be available (the exports) by the time Drupal's behaviors kick in.

So ... async magic/reading 4 hours of messages of cool kids using nodejs and I found a way. Why also upgrading?

Found out that PDF.JS (2.x, one we had) could not read PDFs with "small defects" like many coming from the Internet Archive and older repos. Now those work. Pull coming tomorrow

patdunlavey commented 3 months ago

@DiegoPino I'm curious if this PDF.JS upgrade addresses accessibility issues with the 2.x version? We just received an accessibility audit of one of our sites that found a lot of issues with PDF.JS.

DiegoPino commented 3 months ago

@patdunlavey I have no idea. Could you share the accessibility issues there? Are those things we/could tap in?

DiegoPino commented 3 months ago

@patdunlavey i would love to have those as soon as possible, I need to move into other tasks (paging on IABookreader) + date Facet widgets and I fear things might fall out of radar. Will wait until tomorrow before making my pull.

mlohnash commented 3 months ago

@DiegoPino and @patdunlavey

I have made an excerpt from the recent CA-R accessibility audit with only the identified PDF.JS issues for Diego.

https://docs.google.com/spreadsheets/d/1A-gVddjGCrSRLkKzERFu9QlEk05MKIjf/edit?usp=sharing&ouid=101266773125396074198&rtpof=true&sd=true

DiegoPino commented 3 months ago

@mlohnash thanks ❤️ .

Ok this is important/useful.

Here is the issue. Archipelago does not provide the full PDF.js interface you are using. Our interface is super simplistic. Next/previous page and full render. All the rest you have there, e.g

https://californiarevealed.org/do/63881621-423b-4b03-918e-48b4934431c1

Is the default/demo viewer the folks at Mozilla provide. That is a custom development/add-on of your vendor (would love to get a pull folks!). And that is great you are doing that.

But what we do provide is the pdf.js binding (we now/via this issue will provide a pdf.mjs really, new as of 2024) so with the upcoming pull you would get what Mozilla has as more recent (keep reading)

This is the important piece for you all (and good news bc nothing in pdfjs is fixed!)

@alliomeria also ping!

DiegoPino commented 3 months ago

@mlohnash better link. This is what can be customized in your theme/custom module for make it accessible https://github.com/mozilla/pdf.js/blob/master/web/viewer.html

mlohnash commented 3 months ago

Thanks @DiegoPino! This is very exciting news. I really appreciate your thorough explanation.