mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-16 21:51:13 +01:00
35 lines
969 B
TypeScript
35 lines
969 B
TypeScript
import {
|
|
LoadingIcon,
|
|
MultipartViewer as BaseMultipartViewer,
|
|
type MultipartViewerProps,
|
|
} from "@yaakapp-internal/ui";
|
|
import { lazy, Suspense } from "react";
|
|
import { renderEditor } from "../core/Editor/renderEditor";
|
|
import { ErrorBoundary } from "../ErrorBoundary";
|
|
import { formatText, textViewerExtensions } from "./TextViewer";
|
|
|
|
const PdfViewer = lazy(() => import("./PdfViewer").then((m) => ({ default: m.PdfViewer })));
|
|
|
|
const textViewerProps = { extensions: textViewerExtensions, formatText, renderEditor };
|
|
|
|
export function MultipartViewer(
|
|
props: Omit<MultipartViewerProps, "renderPdf" | "textViewerProps" | "ErrorBoundary">,
|
|
) {
|
|
return (
|
|
<BaseMultipartViewer
|
|
{...props}
|
|
renderPdf={renderPdf}
|
|
textViewerProps={textViewerProps}
|
|
ErrorBoundary={ErrorBoundary}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function renderPdf(data: Uint8Array) {
|
|
return (
|
|
<Suspense fallback={<LoadingIcon />}>
|
|
<PdfViewer data={data} />
|
|
</Suspense>
|
|
);
|
|
}
|