Skip to content

enhancement: Don't strip iframe url if target is html#3207

Merged
gabestein merged 1 commit intomasterfrom
gs/add-iframe-data-url
Dec 19, 2024
Merged

enhancement: Don't strip iframe url if target is html#3207
gabestein merged 1 commit intomasterfrom
gs/add-iframe-data-url

Conversation

@gabestein
Copy link
Member

Issue(s) Resolved

Because we go from HTML to PDF, where iFrames are not supported, exporting to HTML previously stripped the iFrame url and replaced it with instructions to visit the main document to see interactive content.

This allows HTML exports to maintain the original URL by passing the target into the renderStaticHtml function such that if we target pagedJS outputs, we strip the url, but if we target an html download, we don't strip it.

Test Plan

  1. Visit a Pub with an iframe, e.g. pub/jpfkepm9/draft
  2. Make a small change to regenerate cache
  3. Export HTML
  4. Open the HTML in a browser and make sure the iframe appears and the src is properly set
  5. Export PDF
  6. Scroll to where the iframe would be and make sure it has been stripped and replaced with language about how to view the original.

Screenshots (if applicable)

Optional

Notes/Context/Gotchas

There was only one call-site for renderStaticHtml, so I feel pretty good about this being a very limited change for the better.

Supporting Docs

@gabestein gabestein requested review from isTravis and tefkah December 19, 2024 16:56
Comment on lines +291 to +297
const renderableNodes = pagedTarget
? [filterNonExportableNodes, addHrefsToNotes, blankIframes]
.filter((x): x is (nodes: any) => any => !!x)
.reduce((nodes, fn) => fn(nodes), pubDoc.content)
: [filterNonExportableNodes, addHrefsToNotes]
.filter((x): x is (nodes: any) => any => !!x)
.reduce((nodes, fn) => fn(nodes), pubDoc.content);
Copy link
Member Author

@gabestein gabestein Dec 19, 2024

Choose a reason for hiding this comment

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

I tried to DRY this but these node traversing functions are called in order on each node in the document and then reduced into a single pubDoc, so you can't just, e.g., check for the paged target and then re-run and concatenate only the iFrame nodes (I think)

@pubpubBot pubpubBot temporarily deployed to pubpub-pipel-gs-add-ifr-k0pmqv December 19, 2024 17:08 Inactive
@gabestein gabestein merged commit b116f27 into master Dec 19, 2024
@gabestein gabestein deleted the gs/add-iframe-data-url branch December 19, 2024 19:22
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.

3 participants