Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: add support for image files
Marc Seitzd08f6cadbe63
diff --git a/components/document-upload.tsx b/components/document-upload.tsxindex 6516baca..b1aef508 100644--- a/components/document-upload.tsx+++ b/components/document-upload.tsx@@ -43,6 +43,9 @@ export default function DocumentUpload({[], // ".xlsx""text/csv": [], // ".csv""application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"+ "image/png": [], // ".png"+ "image/jpeg": [], // ".jpeg"+ "image/jpg": [], // ".jpg"}: {"application/pdf": [], // ".pdf"@@ -61,6 +64,9 @@ export default function DocumentUpload({"application/vnd.oasis.opendocument.text": [], // ".odt""image/vnd.dwg": [".dwg"], // ".dwg""image/vnd.dxf": [".dxf"], // ".dxf"+ "image/png": [], // ".png"+ "image/jpeg": [], // ".jpeg"+ "image/jpg": [], // ".jpg"},multiple: false,maxSize: maxSize * 1024 * 1024, // 30 MBdiff --git a/components/documents/add-document-modal.tsx b/components/documents/add-document-modal.tsxindex 8bea68d3..9bcf51f9 100644--- a/components/documents/add-document-modal.tsx+++ b/components/documents/add-document-modal.tsx@@ -86,7 +86,7 @@ export function AddDocumentModal({if (!supportedFileType) {setUploading(false);toast.error(- "Unsupported file format. Please upload a PDF, Powerpoint, Excel, or Word file.",+ "Unsupported file format. Please upload a PDF, Powerpoint, Excel, Word or image file.",);return;}diff --git a/components/shared/icons/files/docs.tsx b/components/shared/icons/files/docs.tsxindex 01c87083..caae6cd1 100644--- a/components/shared/icons/files/docs.tsx+++ b/components/shared/icons/files/docs.tsx@@ -14,12 +14,12 @@ export default function DocsIcon({className={className}xmlns="http://www.w3.org/2000/svg">- <g clip-path="url(#a)">+ <g clipPath="url(#a)"><path fill={isLight ? "#000" : "#fff"} d="M57 59h454v462H57z" /><pathopacity=".999"- fill-rule="evenodd"- clip-rule="evenodd"+ fillRule="evenodd"+ clipRule="evenodd"d="M497.5 31.5h-420c-24.333 6.333-39.667 21.667-46 46v420c6.333 24.333 21.667 39.667 46 46h420c24.333-6.333 39.667-21.667 46-46v-420c-6.333-24.333-21.667-39.667-46-46ZM129.465 268.876h-20v40h357.666v-40H129.465ZM109.87 163.648h357.665v40H109.87v-40ZM129.465 373h-20v40h253.542v-40H129.465Z"fill={isLight ? "#fff" : "#111827"}/>@@ -31,7 +31,7 @@ export default function DocsIcon({height="544"rx="48"stroke={isLight ? "#000" : "#fff"}- stroke-width="32"+ strokeWidth="32"/><defs><clipPath id="a">diff --git a/components/shared/icons/files/image.tsx b/components/shared/icons/files/image.tsxnew file mode 100644index 00000000..30a0465e--- /dev/null+++ b/components/shared/icons/files/image.tsx@@ -0,0 +1,56 @@+export default function ImageFileIcon({+ className,+ isLight = true,+}: {+ className?: string;+ isLight?: boolean;+}) {+ return (+ <svg+ width="576"+ height="576"+ viewBox="0 0 576 576"+ fill="none"+ className={className}+ xmlns="http://www.w3.org/2000/svg"+ >+ <g clipPath="url(#a)">+ <rect+ x="57"+ y="59"+ width="454"+ height="462"+ fill={isLight ? "#000" : "#fff"}+ />+ <path+ opacity="0.999"+ fillRule="evenodd"+ clipRule="evenodd"+ d="M497.5 31.5H77.5C53.1667 37.8333 37.8333 53.1667 31.5 77.5V497.5C37.8333 521.833 53.1667 537.167 77.5 543.5H497.5C521.833 537.167 537.167 521.833 543.5 497.5V77.5C537.167 53.1667 521.833 37.8333 497.5 31.5ZM147 165.889C147 155.457 155.457 147 165.889 147H410.111C420.543 147 429 155.457 429 165.889V301.706L402.48 275.186L402.478 275.185C392.935 265.644 379.994 260.285 366.5 260.285C353.006 260.285 340.065 265.644 330.522 275.185L330.52 275.186L176.706 429H165.889C155.457 429 147 420.543 147 410.111V165.889ZM183.412 461C183.359 461 183.307 461 183.255 461H165.889C137.784 461 115 438.216 115 410.111V165.889C115 137.784 137.784 115 165.889 115H410.111C438.216 115 461 137.784 461 165.889V340.318C461 340.328 461 340.339 461 340.349V410.111C461 438.216 438.216 461 410.111 461H183.412ZM429 346.961V410.111C429 420.543 420.543 429 410.111 429H221.961L353.146 297.815L353.147 297.814C356.689 294.274 361.492 292.285 366.5 292.285C371.508 292.285 376.311 294.274 379.853 297.814L379.854 297.815L429 346.961ZM235.667 216.778C225.235 216.778 216.778 225.235 216.778 235.667C216.778 246.099 225.235 254.556 235.667 254.556C246.099 254.556 254.555 246.099 254.555 235.667C254.555 225.235 246.099 216.778 235.667 216.778ZM184.778 235.667C184.778 207.562 207.561 184.778 235.667 184.778C263.772 184.778 286.555 207.562 286.555 235.667C286.555 263.772 263.772 286.556 235.667 286.556C207.561 286.556 184.778 263.772 184.778 235.667Z"+ fill={isLight ? "#fff" : "#111827"}+ />+ </g>+ <rect+ x="16"+ y="16"+ width="544"+ height="544"+ rx="48"+ stroke={isLight ? "#000" : "#fff"}+ strokeWidth="32"+ />+ <defs>+ <clipPath id="a">+ <rect+ x="32"+ y="32"+ width="512"+ height="512"+ rx="32"+ fill={isLight ? "#fff" : "#111827"}+ />+ </clipPath>+ </defs>+ </svg>+ );+}diff --git a/components/shared/icons/files/pdf.tsx b/components/shared/icons/files/pdf.tsxindex 139050d3..e89b22df 100644--- a/components/shared/icons/files/pdf.tsx+++ b/components/shared/icons/files/pdf.tsx@@ -14,12 +14,12 @@ export default function PdfIcon({className={className}xmlns="http://www.w3.org/2000/svg">- <g clip-path="url(#a)">+ <g clipPath="url(#a)"><path fill={isLight ? "#000" : "#fff"} d="M57 59h454v462H57z" /><pathopacity=".999"- fill-rule="evenodd"- clip-rule="evenodd"+ fillRule="evenodd"+ clipRule="evenodd"d="M497.5 31.5h-420c-24.333 6.333-39.667 21.667-46 46v420c6.333 24.333 21.667 39.667 46 46h420c24.333-6.333 39.667-21.667 46-46v-420c-6.333-24.333-21.667-39.667-46-46ZM103 360V215h57.184c10.994 0 20.359 2.1 28.097 6.301 7.738 4.154 13.636 9.936 17.693 17.346 4.105 7.364 6.158 15.86 6.158 25.489 0 9.629-2.076 18.125-6.228 25.488-4.152 7.363-10.168 13.098-18.047 17.205-7.833 4.106-17.316 6.159-28.451 6.159h-25.761V360H103Zm51.452-71.58h-20.807v-48.357h20.665c5.945 0 10.852 1.015 14.721 3.045 3.869 1.982 6.747 4.791 8.634 8.425 1.935 3.587 2.902 7.788 2.902 12.603 0 4.767-.967 8.991-2.902 12.673-1.887 3.635-4.765 6.49-8.634 8.567-3.822 2.03-8.681 3.044-14.579 3.044ZM283.417 360h-51.381V215h51.806c14.579 0 27.13 2.903 37.651 8.708 10.522 5.759 18.613 14.043 24.275 24.852 5.709 10.808 8.564 23.741 8.564 38.798 0 15.105-2.855 28.085-8.564 38.941-5.662 10.856-13.8 19.187-24.416 24.993-10.569 5.805-23.214 8.708-37.935 8.708Zm-20.736-26.267h19.463c9.058 0 16.678-1.605 22.859-4.815 6.228-3.256 10.899-8.283 14.013-15.08 3.161-6.844 4.742-15.671 4.742-26.48 0-10.714-1.581-19.47-4.742-26.267-3.114-6.797-7.761-11.8-13.942-15.009-6.181-3.21-13.801-4.815-22.86-4.815h-19.533v92.466ZM377.032 215v145h30.645v-59.897h58.953v-25.276h-58.953v-34.551H473V215h-95.968Z"fill={isLight ? "#fff" : "#111827"}/>@@ -31,7 +31,7 @@ export default function PdfIcon({height="544"rx="48"stroke={isLight ? "#000" : "#fff"}- stroke-width="32"+ strokeWidth="32"/><defs><clipPath id="a">diff --git a/components/shared/icons/files/slides.tsx b/components/shared/icons/files/slides.tsxindex 8ac36cca..4f0652e1 100644--- a/components/shared/icons/files/slides.tsx+++ b/components/shared/icons/files/slides.tsx@@ -14,12 +14,12 @@ export default function SlidesIcon({className={className}xmlns="http://www.w3.org/2000/svg">- <g clip-path="url(#a)">+ <g clipPath="url(#a)"><path fill={isLight ? "#000" : "#fff"} d="M57 59h454v462H57z" /><pathopacity=".999"- fill-rule="evenodd"- clip-rule="evenodd"+ fillRule="evenodd"+ clipRule="evenodd"d="M497.5 31.5h-420c-24.333 6.333-39.667 21.667-46 46v420c6.333 24.333 21.667 39.667 46 46h420c24.333-6.333 39.667-21.667 46-46v-420c-6.333-24.333-21.667-39.667-46-46ZM133 160c-19.33 0-35 15.67-35 35v186c0 19.33 15.67 35 35 35h309.347c19.329 0 35-15.67 35-35V195c0-19.33-15.671-35-35-35H133Zm-5 59.347h319.347v136.871H128V219.347Z"fill={isLight ? "#fff" : "#111827"}/>@@ -31,7 +31,7 @@ export default function SlidesIcon({height="544"rx="48"stroke={isLight ? "#000" : "#fff"}- stroke-width="32"+ strokeWidth="32"/><defs><clipPath id="a">diff --git a/components/upload-zone.tsx b/components/upload-zone.tsxindex a767e09d..06ec7ab8 100644--- a/components/upload-zone.tsx+++ b/components/upload-zone.tsx@@ -241,6 +241,9 @@ export default function UploadZone({[], // ".xlsx""text/csv": [], // ".csv""application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"+ "image/png": [], // ".png"+ "image/jpeg": [], // ".jpeg"+ "image/jpg": [], // ".jpg"}: {"application/pdf": [], // ".pdf"@@ -259,6 +262,9 @@ export default function UploadZone({"application/vnd.oasis.opendocument.presentation": [], // ".odp""image/vnd.dwg": [".dwg"], // ".dwg""image/vnd.dxf": [".dxf"], // ".dxf"+ "image/png": [], // ".png"+ "image/jpeg": [], // ".jpeg"+ "image/jpg": [], // ".jpg"},multiple: true,maxSize: maxSize * 1024 * 1024, // 30 MBdiff --git a/components/view/dataroom/dataroom-view.tsx b/components/view/dataroom/dataroom-view.tsxindex a5195016..bfbc57ab 100644--- a/components/view/dataroom/dataroom-view.tsx+++ b/components/view/dataroom/dataroom-view.tsx@@ -23,6 +23,7 @@ import DataroomViewer from "../DataroomViewer";import PagesViewerNew from "../PagesViewerNew";import EmailVerificationMessage from "../email-verification-form";import AdvancedExcelViewer from "../viewer/advanced-excel-viewer";+import ImageViewer from "../viewer/image-viewer";const ExcelViewer = dynamic(() => import("@/components/view/viewer/excel-viewer"),@@ -347,6 +348,31 @@ export default function DataroomView({setDocumentData={setDocumentData}/></div>+ ) : viewData.fileType === "image" ? (+ <div className="bg-gray-950">+ <ImageViewer+ file={viewData.file!}+ linkId={link.id}+ viewId={viewData.viewId}+ isPreview={viewData.isPreview}+ documentId={documentData.id}+ documentName={documentData.name}+ allowDownload={link.allowDownload!}+ feedbackEnabled={link.enableFeedback!}+ screenshotProtectionEnabled={link.enableScreenshotProtection!}+ versionNumber={documentData.documentVersionNumber}+ brand={brand}+ dataroomId={dataroom.id}+ setDocumentData={setDocumentData}+ watermarkConfig={+ link.enableWatermark+ ? (link.watermarkConfig as WatermarkConfig)+ : null+ }+ ipAddress={viewData.ipAddress}+ linkName={link.name ?? `Link #${link.id.slice(-5)}`}+ />+ </div>) : viewData.pages ? (<div className="bg-gray-950"><PagesViewerNewdiff --git a/components/view/view-data.tsx b/components/view/view-data.tsxindex 26a52bdb..a2859821 100644--- a/components/view/view-data.tsx+++ b/components/view/view-data.tsx@@ -11,6 +11,7 @@ import { DEFAULT_DOCUMENT_VIEW_TYPE } from "@/components/view/document-view";import { LinkWithDocument, WatermarkConfig } from "@/lib/types";import AdvancedExcelViewer from "./viewer/advanced-excel-viewer";+import ImageViewer from "./viewer/image-viewer";const ExcelViewer = dynamic(() => import("@/components/view/viewer/excel-viewer"),@@ -76,6 +77,30 @@ export default function ViewData({allowDownload={link.allowDownload!}brand={brand}/>+ ) : viewData.fileType === "image" ? (+ <ImageViewer+ file={viewData.file!}+ linkId={link.id}+ documentId={document.id}+ viewId={viewData.viewId}+ assistantEnabled={document.assistantEnabled}+ allowDownload={link.allowDownload!}+ feedbackEnabled={link.enableFeedback!}+ screenshotProtectionEnabled={link.enableScreenshotProtection!}+ versionNumber={document.versions[0].versionNumber}+ brand={brand}+ showPoweredByBanner={showPoweredByBanner}+ showAccountCreationSlide={showAccountCreationSlide}+ enableQuestion={link.enableQuestion}+ feedback={link.feedback}+ isVertical={document.versions[0].isVertical}+ viewerEmail={viewerEmail}+ watermarkConfig={+ link.enableWatermark ? (link.watermarkConfig as WatermarkConfig) : null+ }+ ipAddress={viewData.ipAddress}+ linkName={link.name ?? `Link #${link.id.slice(-5)}`}+ />) : viewData.pages ? (<PagesViewerNewpages={viewData.pages}diff --git a/components/view/viewer/image-viewer.tsx b/components/view/viewer/image-viewer.tsxnew file mode 100644index 00000000..bac2bbe5--- /dev/null+++ b/components/view/viewer/image-viewer.tsx@@ -0,0 +1,366 @@+import { useRouter } from "next/router";++import { useEffect, useRef, useState } from "react";+import React from "react";++import { Brand, DataroomBrand } from "@prisma/client";+import {+ ReactZoomPanPinchContentRef,+ TransformComponent,+ TransformWrapper,+} from "react-zoom-pan-pinch";+import { toast } from "sonner";++import { WatermarkConfig } from "@/lib/types";+import { cn } from "@/lib/utils";+import { useMediaQuery } from "@/lib/utils/use-media-query";++import { ScreenProtector } from "../ScreenProtection";+import { TDocumentData } from "../dataroom/dataroom-view";+import Nav from "../nav";+import { PoweredBy } from "../powered-by";+import { SVGWatermark } from "../watermark-svg";++const trackPageView = async (data: {+ linkId: string;+ documentId: string;+ viewId?: string;+ duration: number;+ pageNumber: number;+ versionNumber: number;+ dataroomId?: string;+ isPreview?: boolean;+}) => {+ // If the view is a preview, do not track the view+ if (data.isPreview) return;++ await fetch("/api/record_view", {+ method: "POST",+ body: JSON.stringify(data),+ headers: {+ "Content-Type": "application/json",+ },+ });+};++export default function ImageViewer({+ file,+ linkId,+ documentId,+ viewId,+ assistantEnabled,+ allowDownload,+ feedbackEnabled,+ screenshotProtectionEnabled,+ versionNumber,+ brand,+ documentName,+ dataroomId,+ setDocumentData,+ showPoweredByBanner,+ showAccountCreationSlide,+ enableQuestion = false,+ feedback,+ isVertical = false,+ viewerEmail,+ isPreview,+ watermarkConfig,+ ipAddress,+ linkName,+}: {+ file: string;+ linkId: string;+ documentId: string;+ viewId?: string;+ assistantEnabled?: boolean;+ allowDownload: boolean;+ feedbackEnabled: boolean;+ screenshotProtectionEnabled: boolean;+ versionNumber: number;+ brand?: Partial<Brand> | Partial<DataroomBrand> | null;+ documentName?: string;+ dataroomId?: string;+ setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;+ showPoweredByBanner?: boolean;+ showAccountCreationSlide?: boolean;+ enableQuestion?: boolean | null;+ feedback?: {+ id: string;+ data: { question: string; type: string };+ } | null;+ isVertical?: boolean;+ viewerEmail?: string;+ isPreview?: boolean;+ watermarkConfig?: WatermarkConfig | null;+ ipAddress?: string;+ linkName?: string;+}) {+ const router = useRouter();++ const numPages = 1;++ const [pageNumber, setPageNumber] = useState<number>(1); // start on first page++ const [scale, setScale] = useState<number>(1);++ const startTimeRef = useRef(Date.now());+ const visibilityRef = useRef<boolean>(true);+ const containerRef = useRef<HTMLDivElement>(null);+ const pinchRefs = useRef<(ReactZoomPanPinchContentRef | null)[]>([]);+ const imageRefs = useRef<HTMLImageElement | null>(null);++ const [imageDimensions, setImageDimensions] = useState<{+ width: number;+ height: number;+ } | null>(null);++ const { isMobile } = useMediaQuery();++ useEffect(() => {+ const updateImageDimensions = () => {+ let newDimensions: { width: number; height: number } | null = null;++ if (imageRefs.current) {+ newDimensions = {+ width: imageRefs.current.clientWidth,+ height: imageRefs.current.clientHeight,+ };+ }+ setImageDimensions(newDimensions);+ };++ updateImageDimensions();+ window.addEventListener("resize", updateImageDimensions);++ return () => {+ window.removeEventListener("resize", updateImageDimensions);+ };+ }, [pageNumber]);++ useEffect(() => {+ const handleVisibilityChange = () => {+ if (pageNumber > numPages) return;++ if (document.visibilityState === "visible") {+ visibilityRef.current = true;+ startTimeRef.current = Date.now(); // Reset start time when the page becomes visible again+ } else {+ visibilityRef.current = false;+ if (pageNumber <= numPages) {+ const duration = Date.now() - startTimeRef.current;+ trackPageView({+ linkId,+ documentId,+ viewId,+ duration,+ pageNumber: pageNumber,+ versionNumber,+ dataroomId,+ isPreview,+ });+ }+ }+ };++ document.addEventListener("visibilitychange", handleVisibilityChange);++ return () => {+ document.removeEventListener("visibilitychange", handleVisibilityChange);+ };+ }, [pageNumber, numPages]);++ useEffect(() => {+ startTimeRef.current = Date.now();++ if (visibilityRef.current && pageNumber <= numPages) {+ const duration = Date.now() - startTimeRef.current;+ trackPageView({+ linkId,+ documentId,+ viewId,+ duration,+ pageNumber: pageNumber,+ versionNumber,+ dataroomId,+ isPreview,+ });+ }+ }, [pageNumber, numPages]);++ useEffect(() => {+ const handleBeforeUnload = () => {+ if (pageNumber <= numPages) {+ const duration = Date.now() - startTimeRef.current;+ trackPageView({+ linkId,+ documentId,+ viewId,+ duration,+ pageNumber: pageNumber,+ versionNumber,+ dataroomId,+ isPreview,+ });+ }+ };++ window.addEventListener("beforeunload", handleBeforeUnload);++ return () => {+ window.removeEventListener("beforeunload", handleBeforeUnload);+ };+ }, [pageNumber, numPages]);++ useEffect(() => {+ // Remove token and email query parameters on component mount+ const removeQueryParams = (queries: string[]) => {+ const currentQuery = { ...router.query };+ queries.map((query) => delete currentQuery[query]);++ router.replace(+ {+ pathname: router.pathname,+ query: currentQuery,+ },+ undefined,+ { shallow: true },+ );+ };++ if (!dataroomId && router.query.token) {+ removeQueryParams(["token", "email"]);+ }+ }, []); // Run once on mount++ // Function to handle context for screenshotting+ const handleContextMenu = (event: React.MouseEvent<HTMLDivElement>) => {+ if (!screenshotProtectionEnabled) {+ return null;+ }++ event.preventDefault();+ // Close menu on click anywhere+ const clickHandler = () => {+ document.removeEventListener("click", clickHandler);+ };+ document.addEventListener("click", clickHandler);++ toast.info("Context menu has been disabled.");+ };++ return (+ <>+ <Nav+ pageNumber={pageNumber}+ numPages={numPages}+ allowDownload={allowDownload}+ brand={brand}+ viewId={viewId}+ linkId={linkId}+ documentName={documentName}+ isDataroom={dataroomId ? true : false}+ setDocumentData={setDocumentData}+ documentRefs={pinchRefs}+ isMobile={isMobile}+ isPreview={isPreview}+ hasWatermark={watermarkConfig ? true : false}+ />+ <div+ style={{ height: "calc(100dvh - 64px)" }}+ className="relative flex items-center"+ >+ <div+ className="relative flex h-full w-full flex-row"+ ref={containerRef}+ >+ <div+ className="flex w-full flex-row justify-center"+ onContextMenu={handleContextMenu}+ >+ <TransformWrapper+ initialScale={scale}+ initialPositionX={0}+ initialPositionY={0}+ disabled={isMobile}+ panning={{+ lockAxisY: false,+ velocityDisabled: true,+ wheelPanning: false,+ }}+ wheel={{ disabled: true }}+ pinch={{ disabled: true }}+ doubleClick={{ disabled: true }}+ onZoom={(ref) => {+ setScale(ref.state.scale);+ }}+ ref={(ref) => {+ pinchRefs.current[0] = ref;+ }}+ customTransform={(x: number, y: number, scale: number) => {+ // Keep the translateY value constant+ if (isVertical) {+ const transform = `translate(${x}px, ${0 * y * -2}px) scale(${scale})`;+ return transform;+ }+ const transform = `translate(${x}px, ${y}px) scale(${scale})`;+ return transform;+ }}+ >+ <TransformComponent+ wrapperClass={cn(+ "!h-full",+ isMobile+ ? "!overflow-x-clip !overflow-y-clip"+ : "!overflow-x-visible !overflow-y-clip",+ )}+ contentClass="!h-full"+ >+ <div className="relative my-auto block w-full">+ <img+ className="!pointer-events-auto object-contain"+ style={{+ maxHeight: "calc(100dvh - 64px)",+ }}+ ref={(ref) => {+ imageRefs.current = ref;+ if (ref) {+ ref.onload = () =>+ setImageDimensions({+ width: ref.clientWidth,+ height: ref.clientHeight,+ });+ }+ }}+ src={file}+ alt="Image 1"+ />++ {/* Add Watermark Component */}+ {watermarkConfig ? (+ <SVGWatermark+ config={watermarkConfig}+ viewerData={{+ email: viewerEmail,+ date: new Date().toLocaleDateString(),+ time: new Date().toLocaleTimeString(),+ link: linkName,+ ipAddress: ipAddress,+ }}+ documentDimensions={+ imageDimensions ?? { width: 0, height: 0 }+ }+ pageIndex={0}+ />+ ) : null}+ </div>+ </TransformComponent>+ </TransformWrapper>+ </div>+ </div>++ {screenshotProtectionEnabled ? <ScreenProtector /> : null}+ {showPoweredByBanner ? <PoweredBy linkId={linkId} /> : null}+ </div>+ </>+ );+}diff --git a/lib/constants.ts b/lib/constants.tsindex 6b975f0d..3397fa42 100644--- a/lib/constants.ts+++ b/lib/constants.ts@@ -90,6 +90,9 @@ export const SUPPORTED_DOCUMENT_MIME_TYPES = ["application/vnd.oasis.opendocument.text", // .odt"image/vnd.dwg", // .dwg"image/vnd.dxf", // .dxf+ "image/png", // .png+ "image/jpeg", // .jpeg+ "image/jpg", // .jpg];export const SUPPORTED_DOCUMENT_SIMPLE_TYPES = [@@ -99,4 +102,5 @@ export const SUPPORTED_DOCUMENT_SIMPLE_TYPES = ["slides","docs","cad",+ "image",];diff --git a/lib/utils/get-content-type.ts b/lib/utils/get-content-type.tsindex 1ed22df5..c3840ed2 100644--- a/lib/utils/get-content-type.ts+++ b/lib/utils/get-content-type.ts@@ -18,6 +18,10 @@ export function getSupportedContentType(contentType: string): string | null {case "image/vnd.dwg":case "image/vnd.dxf":return "cad";+ case "image/png":+ case "image/jpeg":+ case "image/jpg":+ return "image";default:return null;}@@ -53,6 +57,12 @@ export function getExtensionFromContentType(return "dwg";case "image/vnd.dxf":return "dxf";+ case "image/png":+ return "png";+ case "image/jpeg":+ return "jpeg";+ case "image/jpg":+ return "jpg";default:return null;}diff --git a/lib/utils/get-file-icon.tsx b/lib/utils/get-file-icon.tsxindex 4c271f2e..acaa9db9 100644--- a/lib/utils/get-file-icon.tsx+++ b/lib/utils/get-file-icon.tsx@@ -1,7 +1,8 @@-import { FileIcon, ImageIcon } from "lucide-react";+import { FileIcon } from "lucide-react";import CadIcon from "@/components/shared/icons/files/cad";import DocsIcon from "@/components/shared/icons/files/docs";+import ImageFileIcon from "@/components/shared/icons/files/image";import NotionIcon from "@/components/shared/icons/files/notion";import PdfIcon from "@/components/shared/icons/files/pdf";import SheetIcon from "@/components/shared/icons/files/sheet";@@ -22,9 +23,9 @@ export function fileIcon({return <PdfIcon className={className} isLight={isLight} />;case "image/png":case "image/jpeg":- case "image/gif":case "image/jpg":- return <ImageIcon className={className} />;+ case "image":+ return <ImageFileIcon className={className} isLight={isLight} />;case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":case "application/msword":case "application/vnd.oasis.opendocument.text":diff --git a/pages/api/views-dataroom.ts b/pages/api/views-dataroom.tsindex ac4c8778..e8408243 100644--- a/pages/api/views-dataroom.ts+++ b/pages/api/views-dataroom.ts@@ -505,7 +505,7 @@ export default async function handle(return;}- if (documentVersion.type === "pdf") {+ if (documentVersion.type === "pdf" || documentVersion.type === "image") {documentVersion.file = await getFile({data: documentVersion.file,type: documentVersion.storageType,@@ -551,7 +551,9 @@ export default async function handle(viewId: !isPreview && newView ? newView.id : undefined,isPreview: isPreview ? true : undefined,file:- (documentVersion && documentVersion.type === "pdf") ||+ (documentVersion &&+ (documentVersion.type === "pdf" ||+ documentVersion.type === "image")) ||(documentVersion && useAdvancedExcelViewer)? documentVersion.file: undefined,diff --git a/pages/api/views.ts b/pages/api/views.tsindex efad9234..b0c35d3b 100644--- a/pages/api/views.ts+++ b/pages/api/views.ts@@ -357,7 +357,7 @@ export default async function handle(return;}- if (documentVersion.type === "pdf") {+ if (documentVersion.type === "pdf" || documentVersion.type === "image") {documentVersion.file = await getFile({data: documentVersion.file,type: documentVersion.storageType,@@ -393,7 +393,9 @@ export default async function handle(viewId: !isPreview && newView ? newView.id : undefined,isPreview: isPreview ? true : undefined,file:- (documentVersion && documentVersion.type === "pdf") ||+ (documentVersion &&+ (documentVersion.type === "pdf" ||+ documentVersion.type === "image")) ||(documentVersion && useAdvancedExcelViewer)? documentVersion.file: undefined,