Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

add google viewer for all other files

Marc Seitz7347a8b393d1
diff --git a/pages/view/[linkId].tsx b/pages/view/[linkId].tsx
index 40d46a49..48628e66 100644
--- a/pages/view/[linkId].tsx
+++ b/pages/view/[linkId].tsx
@@ -2,12 +2,8 @@ import { GetServerSideProps } from "next";
import React, { useState } from "react";
import prisma from "@/lib/prisma";
import EmailForm from "@/components/EmailForm";
-// import { Document, Page, pdfjs } from "react-pdf";
-// import "react-pdf/dist/esm/Page/AnnotationLayer.css";
import Link from "next/link";
-// pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.js`;
-
const DocumentView = ({
document,
linkId,
@@ -45,24 +41,11 @@ const DocumentView = ({
return <EmailForm onSubmitHandler={handleSubmit} setEmail={setEmail} />;
}
- // if (document.file.includes(".pdf")) {
- // return (
- // <div>
- // <Document file={document.file} onLoadSuccess={onDocumentLoadSuccess}>
- // {Array.from(new Array(numPages), (el, index) => (
- // <Page
- // key={`page_${index + 1}`}
- // pageNumber={index + 1}
- // renderTextLayer={false}
- // />
- // ))}
- // </Document>
- // </div>
- // );
- // }
if (
document.file.includes(".docx") ||
document.file.includes(".pptx") ||
+ document.file.includes(".xlsx") ||
+ document.file.includes(".xls") ||
document.file.includes(".doc") ||
document.file.includes(".ppt")
) {
@@ -75,33 +58,12 @@ const DocumentView = ({
</div>
);
}
- if (
- document.file.includes(".png") ||
- document.file.includes(".jpeg") ||
- document.file.includes(".gif") ||
- document.file.includes(".jpg")
- ) {
- return (
- <div className="h-screen bg-gray-900">
- <img className="w-full h-full" src={document.file} />
- </div>
- );
- }
-
return (
- <div className="h-screen bg-black flex flex-col items-center space-y-4">
- <div className="text-center">
- <div className="text-white text-2xl mt-10">{document.name}</div>
- <p className="text-gray-400">
- This file cannot be viewed in the browser.
- </p>
- </div>
- <Link
- href={document.file}
- className="rounded px-4 py-2 bg-gray-800 text-gray-300 hover:bg-gray-700 hover:text-white"
- >
- Download file
- </Link>
+ <div className="h-screen bg-gray-900">
+ <iframe
+ className="w-full h-full"
+ src={`https://docs.google.com/viewer?url=${document.file}&embedded=true`}
+ ></iframe>
</div>
);
};