Stelle PDFs auf iPhone und iPad seitenweise dar und nutze das Legacy-Build von pdf.js.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b2d0c298e
commit
07e46c77f1
6 files changed
+100
-10
No files matched your search
@@ -1,10 +1,11 @@
|
||||
import { DocumentView } from "../pages/DocumentView.jsx";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { api, documentToText, downloadMailPart, fetchExternal, fetchMailPart, markDirty, textToDocument } from "../api.js";
|
||||
import { MailAttachments, MailBody } from "../mail-view.jsx";
|
||||
import { MarkdownView } from "../markdown.jsx";
|
||||
import { NoteEditor } from "../notes.jsx";
|
||||
import { DirectionColumn, directionWord } from "../pages/content.jsx";
|
||||
import workerSrc from "pdfjs-dist/build/pdf.worker.min.mjs?url";
|
||||
import workerSrc from "pdfjs-dist/legacy/build/pdf.worker.min.mjs?url";
|
||||
import { editors, registerStage } from "./registry.jsx";
|
||||
|
||||
function previewKind(type, filename) {
|
||||
@@ -181,7 +182,7 @@ export function MailStage({ element, context, shownDirection }) {
|
||||
setMedia("pdf");
|
||||
try {
|
||||
const bytes = await blob.arrayBuffer();
|
||||
const pdfjs = await import("pdfjs-dist");
|
||||
const pdfjs = await import("pdfjs-dist/legacy/build/pdf.mjs");
|
||||
pdfjs.GlobalWorkerOptions.workerSrc = workerSrc;
|
||||
const doc = await pdfjs.getDocument({ data: bytes }).promise;
|
||||
if (!alive) {
|
||||
@@ -260,7 +261,7 @@ export function MailStage({ element, context, shownDirection }) {
|
||||
{shownFile && phase === "loading" ? <p className="muted">Die Anlage wird geladen …</p> : null}
|
||||
{media === "image" && blobUrl ? <img className="reader-image" alt={shownFile?.filename || element.title} src={blobUrl} /> : null}
|
||||
{media === "pdf" && pdf ? <canvas ref={canvasRef} className="reader-canvas" /> : null}
|
||||
{media === "pdf-frame" && blobUrl ? <iframe className="reader-frame" title={shownFile?.filename || element.title} src={blobUrl} /> : null}
|
||||
{media === "pdf-frame" && blobUrl ? <DocumentView title={shownFile?.filename || element.title} url={blobUrl} /> : null}
|
||||
{media === "other" && blobUrl ? <a href={blobUrl} target="_blank" rel="noreferrer">Anlage öffnen</a> : null}
|
||||
{pages > 1 ? (
|
||||
<div className="reader-pages">
|
||||
|
||||
Reference in new issue
Block a user