diff --git a/apps/client/src/widgets/type_widgets/File.tsx b/apps/client/src/widgets/type_widgets/File.tsx index f1d0de6fa..1d69e3b71 100644 --- a/apps/client/src/widgets/type_widgets/File.tsx +++ b/apps/client/src/widgets/type_widgets/File.tsx @@ -1,13 +1,11 @@ import "./File.css"; -import { useEffect } from "preact/hooks"; - import FNote from "../../entities/fnote"; import { t } from "../../services/i18n"; import { getUrlForDownload } from "../../services/open"; -import server from "../../services/server"; import Alert from "../react/Alert"; import { useNoteBlob } from "../react/hooks"; +import PdfPreview from "./file/Pdf"; import { TypeWidgetProps } from "./type_widget"; const TEXT_MAX_NUM_CHARS = 5000; @@ -44,28 +42,6 @@ function TextPreview({ content }: { content: string }) { ); } -function PdfPreview({ note }: { note: FNote }) { - useEffect(() => { - function handleMessage(event: MessageEvent) { - if (event.data?.type === "pdfjs-viewer-document-modified" && event.data?.data) { - const blob = new Blob([event.data.data], { type: note.mime }); - server.upload(`notes/${note.noteId}/file`, new File([blob], note.title, { type: note.mime })); - } - } - - window.addEventListener("message", handleMessage); - return () => { - window.removeEventListener("message", handleMessage); - }; - }, [ note ]); - - return ( -