Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: add support for kml / kmz file type
Marc Seitzc913d985dc00
diff --git a/components/document-upload.tsx b/components/document-upload.tsxindex 49b8179d..cea578f5 100644--- a/components/document-upload.tsx+++ b/components/document-upload.tsx@@ -83,6 +83,8 @@ export default function DocumentUpload({"video/x-msvideo": [], // ".avi""video/webm": [], // ".webm""video/ogg": [], // ".ogg"+ "application/vnd.google-earth.kml+xml": [".kml"], // ".kml"+ "application/vnd.google-earth.kmz": [".kmz"], // ".kmz"},multiple: false,onDropAccepted: (acceptedFiles) => {diff --git a/components/shared/icons/files/map.tsx b/components/shared/icons/files/map.tsxnew file mode 100644index 00000000..128ef681--- /dev/null+++ b/components/shared/icons/files/map.tsx@@ -0,0 +1,56 @@+export default function MapIcon({+ 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(#clip0_map)">+ <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.5ZM287.5 117.5C229.5 117.5 182.5 164.5 182.5 222.5C182.5 299.5 287.5 417.5 287.5 417.5C287.5 417.5 392.5 299.5 392.5 222.5C392.5 164.5 345.5 117.5 287.5 117.5ZM287.5 262.5C265.5 262.5 247.5 244.5 247.5 222.5C247.5 200.5 265.5 182.5 287.5 182.5C309.5 182.5 327.5 200.5 327.5 222.5C327.5 244.5 309.5 262.5 287.5 262.5Z"+ 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="clip0_map">+ <rect+ x="32"+ y="32"+ width="512"+ height="512"+ rx="32"+ fill={isLight ? "#fff" : "#111827"}+ />+ </clipPath>+ </defs>+ </svg>+ );+}diff --git a/components/upload-zone.tsx b/components/upload-zone.tsxindex c46ec208..2e9bcefd 100644--- a/components/upload-zone.tsx+++ b/components/upload-zone.tsx@@ -59,6 +59,8 @@ const allAcceptableDropZoneMimeTypes = {"video/quicktime": [], // ".mov""video/x-msvideo": [], // ".avi""video/ogg": [], // ".ogg"+ "application/vnd.google-earth.kml+xml": [".kml"], // ".kml"+ "application/vnd.google-earth.kmz": [".kmz"], // ".kmz"};interface FileWithPaths extends File {@@ -263,6 +265,14 @@ export default function UploadZone({contentType = "application/vnd.ms-excel.sheet.macroEnabled.12";}+ if (+ uploadResult.fileName.endsWith(".kml") ||+ uploadResult.fileName.endsWith(".kmz")+ ) {+ supportedFileType = "map";+ contentType = `application/vnd.google-earth.${uploadResult.fileName.endsWith(".kml") ? "kml+xml" : "kmz"}`;+ }+const documentData: DocumentData = {key: uploadResult.id,supportedFileType: supportedFileType,diff --git a/lib/constants.ts b/lib/constants.tsindex 788c6c3d..93c47776 100644--- a/lib/constants.ts+++ b/lib/constants.ts@@ -85,6 +85,8 @@ export const SUPPORTED_DOCUMENT_MIME_TYPES = ["video/x-msvideo", // .avi"video/webm", // .webm"video/ogg", // .ogg+ "application/vnd.google-earth.kml+xml", // .kml+ "application/vnd.google-earth.kmz", // .kmz];export const SUPPORTED_DOCUMENT_SIMPLE_TYPES = [@@ -97,6 +99,7 @@ export const SUPPORTED_DOCUMENT_SIMPLE_TYPES = ["image","zip","video",+ "map",] as const;export const VIDEO_EVENT_TYPES = [diff --git a/lib/documents/create-document.ts b/lib/documents/create-document.tsindex 823ba322..0d320536 100644--- a/lib/documents/create-document.ts+++ b/lib/documents/create-document.ts@@ -5,7 +5,7 @@ export type DocumentData = {key: string;storageType: DocumentStorageType;contentType: string; // actual file mime type- supportedFileType: string; // papermark types: "pdf", "sheet", "docs", "slides"+ supportedFileType: string; // papermark types: "pdf", "sheet", "docs", "slides", "map", "zip"fileSize: number | undefined; // file size in bytes};diff --git a/lib/utils/get-content-type.ts b/lib/utils/get-content-type.tsindex 52072656..22f2ea15 100644--- a/lib/utils/get-content-type.ts+++ b/lib/utils/get-content-type.ts@@ -32,6 +32,9 @@ export function getSupportedContentType(contentType: string): string | null {case "video/webm":case "video/ogg":return "video";+ case "application/vnd.google-earth.kml+xml":+ case "application/vnd.google-earth.kmz":+ return "map";default:return null;}@@ -85,6 +88,10 @@ export function getExtensionFromContentType(return "webm";case "video/ogg":return "ogg";+ case "application/vnd.google-earth.kml+xml":+ return "kml";+ case "application/vnd.google-earth.kmz":+ return "kmz";default:return null;}diff --git a/lib/utils/get-file-icon.tsx b/lib/utils/get-file-icon.tsxindex d605cbff..ffe9a57c 100644--- a/lib/utils/get-file-icon.tsx+++ b/lib/utils/get-file-icon.tsx@@ -3,6 +3,7 @@ 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 MapIcon from "@/components/shared/icons/files/map";import NotionIcon from "@/components/shared/icons/files/notion";import PdfIcon from "@/components/shared/icons/files/pdf";import SheetIcon from "@/components/shared/icons/files/sheet";@@ -56,6 +57,10 @@ export function fileIcon({case "video/x-msvideo":case "video":return <VideoIcon className={className} isLight={isLight} />;+ case "application/vnd.google-earth.kml+xml":+ case "application/vnd.google-earth.kmz":+ case "map":+ return <MapIcon className={className} isLight={isLight} />;default:return <FileIcon className={className} />;}diff --git a/pages/api/teams/[teamId]/documents/index.ts b/pages/api/teams/[teamId]/documents/index.tsindex a432be93..3d641b8c 100644--- a/pages/api/teams/[teamId]/documents/index.ts+++ b/pages/api/teams/[teamId]/documents/index.ts@@ -221,7 +221,7 @@ export default async function handle(});// determine if the document is download only- const isDownloadOnly = type === "zip";+ const isDownloadOnly = type === "zip" || type === "map";// Save data to the databaseconst document = await prisma.document.create({