Skip to content

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

Merge branch 'main' of https://github.com/Aashish-Upadhyay-101/papermark into clickable-docs-links

Aashish-Upadhyay-1014084748f8765
diff --cc components/view/PagesViewer.tsx
index c9ebf358,1aef723e..0b22b8bf
--- a/components/view/PagesViewer.tsx
+++ b/components/view/PagesViewer.tsx
@@@ -148,8 -150,10 +150,11 @@@ export default function PagesViewer(
pageNumber={pageNumber}
numPages={numPages}
assistantEnabled={assistantEnabled}
+ allowDownload={allowDownload}
brand={brand}
+ viewId={viewId}
+ linkId={linkId}
+ embeddedLinks={pages[pageNumber - 1].embeddedLinks}
/>
<div
style={{ height: "calc(100vh - 64px)" }}
diff --cc components/view/nav.tsx
index 3d218d14,197a8271..22d37d40
--- a/components/view/nav.tsx
+++ b/components/view/nav.tsx
@@@ -5,52 -4,45 +4,55 @@@ import PapermarkSparkle from "../shared
import { Download } from "lucide-react";
import { Brand } from "@prisma/client";
import Image from "next/image";
+ import { toast } from "sonner";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import DropDown from "../web/alternatives/dropdownproto";
+
+// TODO: trigger dev job start garni ani matra file upload garni ho k
export default function Nav({
pageNumber,
numPages,
allowDownload,
assistantEnabled,
- file,
brand,
+ viewId,
+ linkId,
+ type,
+ embeddedLinks,
}: {
pageNumber?: number;
numPages?: number;
allowDownload?: boolean;
assistantEnabled?: boolean;
- file?: { name: string; url: string };
brand?: Brand;
+ embeddedLinks?: string[];
+ viewId?: string;
+ linkId?: string;
+ type?: "pdf" | "notion";
}) {
- const router = useRouter();
- const { linkId } = router.query as { linkId: string };
-
- async function downloadFile(e: React.MouseEvent<HTMLButtonElement>) {
- if (!allowDownload || !file) return;
+ const downloadFile = async () => {
+ if (!allowDownload || type === "notion") return;
try {
- //get file data
- const response = await fetch(file.url);
- const fileData = await response.blob();
+ const response = await fetch(`/api/links/download`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ linkId, viewId }),
+ });
- //create <a/> to download the file
- const a = document.createElement("a");
- a.href = window.URL.createObjectURL(fileData);
- a.download = file.name;
- document.body.appendChild(a);
- a.click();
+ if (!response.ok) {
+ toast.error("Error downloading file");
+ return;
+ }
- //clean up used resources
- document.body.removeChild(a);
- window.URL.revokeObjectURL(a.href);
+ const { downloadUrl } = await response.json();
+ window.open(downloadUrl, "_blank");
} catch (error) {
console.error("Error downloading file:", error);
}