🖼️ fix: Show EMF/WMF Pictures in PowerPoint Previews - #85
Closed
TomasPalsson wants to merge 1 commit into
Closed
TomasPalsson wants to merge 1 commit into
TomasPalsson wants to merge 1 commit into
Conversation
pptx-preview turns EMF/WMF media into data:image/x-emf URIs, which no browser can decode, so template logos stored as metafiles render as broken images. Convert them to SVG on the server with emf-converter (pinned 4.8.7, Apache-2.0, no deps), embed the SVGs keyed by a hash of the media's base64, and swap them into the rendered <img> elements once the slides are drawn. Bounded by count, per-file, total-input, output and time budgets; a deck whose preview fits today never loses it to the added map.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
Author
|
Superseded by LibreChat-AI#16672, which is now the source of this change. The squashed commit from that PR is cherry-picked onto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PowerPoint templates often store logos as EMF/WMF (Windows metafiles).
pptx-previewturns them intodata:image/x-emfURIs, which no browser can decode, so the logos render as broken images in the artifact preview. Seen with a customer template where 8 of 11 media files are EMF logos in the slide layouts.Fix
Server:
extractPptxMetafileSvgs(newpackages/api/src/files/documents/metafiles.ts) convertsppt/media/image*.emf|wmfto SVG withemf-converter(pinned4.8.7, Apache-2.0, zero deps), keyed by an FNV-1a hash of the entry's base64. That is exactly what pptx-preview puts inimg.src.html.ts: the map is embedded as<script id="lc-metafiles" type="application/json">, with<escaped. After the slides render, the iframe swaps matching<img>sources for the SVG data URIs. The swap is wrapped in try/catch and can never trigger the fallback.Budgets:
If the map would push a deck over
OFFICE_HTML_OUTPUT_CAP, the deck is retried without the map, so no deck that previews today regresses to the slide list.The CSP is unchanged (
img-srcalready allowsdata:). The DOCX path is untouched.Verification
cd packages/api && npx jest src/files/documents src/files/code: 18 suites, 536 tests passing, 9 of them new.<img>; after, 3 loaded SVG logos.Not covered
<img>is swapped.@napi-rs/canvas. These are skipped, not broken.