Skip to content

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

improvement

Ashish Viradiya1352c9872533
diff --git a/components/links/link-sheet/index.tsx b/components/links/link-sheet/index.tsx
index 12c518b3..d27a13c7 100644
--- a/components/links/link-sheet/index.tsx
+++ b/components/links/link-sheet/index.tsx
@@ -229,7 +229,7 @@ export default function LinkSheet({
const newExpiresAt = new Date();
newExpiresAt.setSeconds(
newExpiresAt.getSeconds() +
- (preset.expiresIn as { value: number }).value,
+ (JSON.parse(preset.expiresIn as string) as { value: number }).value,
);
expiresAt = newExpiresAt;
} else {
@@ -255,6 +255,8 @@ export default function LinkSheet({
metaFavicon: preset.metaFavicon || prev.metaFavicon,
allowDownload: preset.allowDownload || prev.allowDownload,
expiresAt,
+ enableScreenshotProtection:
+ preset.enableScreenshotProtection || prev.enableScreenshotProtection,
};
});
diff --git a/lib/zod/schemas/presets.ts b/lib/zod/schemas/presets.ts
index ba89e2bf..e1919b80 100644
--- a/lib/zod/schemas/presets.ts
+++ b/lib/zod/schemas/presets.ts
@@ -57,6 +57,9 @@ export const presetDataSchema = z.object({
type: z.enum(["natural", "normal"]),
})
.nullable(),
+
+ // Screenshot Protection
+ enableScreenshotProtection: z.boolean(),
});
export type PresetDataSchema = z.infer<typeof presetDataSchema>;
diff --git a/pages/api/teams/[teamId]/presets/[id].ts b/pages/api/teams/[teamId]/presets/[id].ts
index 5ebd9bb8..9648a3a0 100644
--- a/pages/api/teams/[teamId]/presets/[id].ts
+++ b/pages/api/teams/[teamId]/presets/[id].ts
@@ -101,6 +101,9 @@ export default async function handle(
watermarkConfig: validatedData.watermarkConfig
? JSON.stringify(validatedData.watermarkConfig)
: Prisma.JsonNull,
+ expiresIn: validatedData.expiresIn
+ ? JSON.stringify(validatedData.expiresIn)
+ : Prisma.JsonNull,
},
});
diff --git a/pages/api/teams/[teamId]/presets/index.ts b/pages/api/teams/[teamId]/presets/index.ts
index e2878cd2..6db283d3 100644
--- a/pages/api/teams/[teamId]/presets/index.ts
+++ b/pages/api/teams/[teamId]/presets/index.ts
@@ -83,6 +83,9 @@ export default async function handle(
watermarkConfig: validatedData.watermarkConfig
? JSON.stringify(validatedData.watermarkConfig)
: undefined,
+ expiresIn: validatedData.expiresIn
+ ? JSON.stringify(validatedData.expiresIn)
+ : undefined,
},
});
return res
diff --git a/pages/settings/presets/[id].tsx b/pages/settings/presets/[id].tsx
index 22f56aa2..c5252a85 100644
--- a/pages/settings/presets/[id].tsx
+++ b/pages/settings/presets/[id].tsx
@@ -1,7 +1,11 @@
import { useRouter } from "next/router";
+
+
import { FormEvent, useEffect, useState } from "react";
+
+
import { useTeam } from "@/context/team-context";
import { PlanEnum } from "@/ee/stripe/constants";
import { LinkPreset } from "@prisma/client";
@@ -9,11 +13,15 @@ import { AlertCircle, ArrowLeft, Trash2, X } from "lucide-react";
import { toast } from "sonner";
import useSWR from "swr";
+
+
import { usePlan } from "@/lib/swr/use-billing";
import useLimits from "@/lib/swr/use-limits";
import { WatermarkConfig } from "@/lib/types";
import { fetcher } from "@/lib/utils";
+
+
import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
import AppLayout from "@/components/layouts/app";
import { DEFAULT_LINK_TYPE } from "@/components/links/link-sheet";
@@ -27,20 +35,20 @@ import ExpirationInSection from "@/components/links/link-sheet/expirationIn-sect
import { LinkUpgradeOptions } from "@/components/links/link-sheet/link-options";
import OGSection from "@/components/links/link-sheet/og-section";
import PasswordSection from "@/components/links/link-sheet/password-section";
+import ScreenshotProtectionSection from "@/components/links/link-sheet/screenshot-protection-section";
import WatermarkSection from "@/components/links/link-sheet/watermark-section";
import Preview from "@/components/settings/og-preview";
import { SettingsHeader } from "@/components/settings/settings-header";
-import {
- Alert,
- AlertClose,
- AlertDescription,
- AlertTitle,
-} from "@/components/ui/alert";
+import { Alert, AlertClose, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Separator } from "@/components/ui/separator";
+
+
+
+
export type PRESET_DATA = Partial<DEFAULT_LINK_TYPE> & {
name: string;
enableAllowList?: boolean;
@@ -109,14 +117,18 @@ export default function EditPreset() {
? (JSON.parse(preset.watermarkConfig as string) as WatermarkConfig)
: null;
+ const expiresIn = preset.expiresIn
+ ? (JSON.parse(preset.expiresIn as string) as {
+ value: number;
+ type: "natural" | "normal";
+ })
+ : null;
+
setData({
id: null,
name: preset.name,
expiresAt: preset.expiresAt,
- expiresIn: preset.expiresIn as {
- value: number;
- type: "natural" | "normal";
- },
+ expiresIn: expiresIn,
password: preset.password,
emailProtected: preset.emailProtected ?? true,
emailAuthenticated: preset.emailAuthenticated ?? false,
@@ -131,6 +143,7 @@ export default function EditPreset() {
enableWatermark: preset.enableWatermark ?? false,
watermarkConfig: watermarkConfig,
pId: preset.pId,
+ enableScreenshotProtection: preset.enableScreenshotProtection ?? false,
});
}
}, [preset]);
@@ -174,6 +187,7 @@ export default function EditPreset() {
expiresAt: data.expiresAt,
expiresIn: data.expiresIn,
pId: data.pId,
+ enableScreenshotProtection: data.enableScreenshotProtection,
}),
});
@@ -372,6 +386,18 @@ export default function EditPreset() {
data={data as any}
setData={setData as any}
/>
+ <ScreenshotProtectionSection
+ data={data as any}
+ setData={setData as any}
+ isAllowed={
+ isTrial ||
+ (isPro && allowAdvancedLinkControls) ||
+ isBusiness ||
+ isDatarooms ||
+ isDataroomsPlus
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
<ExpirationSection
data={data as any}
setData={setData as any}
diff --git a/pages/settings/presets/index.tsx b/pages/settings/presets/index.tsx
index 05e3054b..83727891 100644
--- a/pages/settings/presets/index.tsx
+++ b/pages/settings/presets/index.tsx
@@ -153,7 +153,14 @@ export default function Presets() {
{preset.expiresIn && (
<Badge variant="time">
Expires in{" "}
- {formatExpirationTime((preset.expiresIn as { type: "natural" | "normal"; value: number }).value)}
+ {formatExpirationTime(
+ preset.expiresIn
+ ? (JSON.parse(preset.expiresIn as string) as {
+ type: "natural" | "normal";
+ value: number;
+ }).value
+ : 0,
+ )}
</Badge>
)}
</div>
diff --git a/pages/settings/presets/new.tsx b/pages/settings/presets/new.tsx
index 9294c6ba..abe6e1b8 100644
--- a/pages/settings/presets/new.tsx
+++ b/pages/settings/presets/new.tsx
@@ -27,6 +27,7 @@ import ExpirationInSection from "@/components/links/link-sheet/expirationIn-sect
import { LinkUpgradeOptions } from "@/components/links/link-sheet/link-options";
import OGSection from "@/components/links/link-sheet/og-section";
import PasswordSection from "@/components/links/link-sheet/password-section";
+import ScreenshotProtectionSection from "@/components/links/link-sheet/screenshot-protection-section";
import WatermarkSection from "@/components/links/link-sheet/watermark-section";
import Preview from "@/components/settings/og-preview";
import { SettingsHeader } from "@/components/settings/settings-header";
@@ -120,6 +121,7 @@ export default function NewPreset() {
allowDownload: data.allowDownload,
expiresAt: data.expiresAt,
expiresIn: data.expiresIn || null,
+ enableScreenshotProtection: data.enableScreenshotProtection,
}),
});
@@ -213,6 +215,18 @@ export default function NewPreset() {
handleUpgradeStateChange={handleUpgradeStateChange}
/>
<AllowDownloadSection data={data} setData={setData} />
+ <ScreenshotProtectionSection
+ data={data}
+ setData={setData}
+ isAllowed={
+ isTrial ||
+ (isPro && allowAdvancedLinkControls) ||
+ isBusiness ||
+ isDatarooms ||
+ isDataroomsPlus
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
<ExpirationSection data={data} setData={setData} />
<ExpirationInSection data={data} setData={setData} />
</div>
@@ -301,4 +315,4 @@ export default function NewPreset() {
/>
</AppLayout>
);
-}
+}
\ No newline at end of file
diff --git a/prisma/migrations/20250429175856_update_expires_in/migration.sql b/prisma/migrations/20250430170529_preset_field/migration.sql
similarity index 64%
rename from prisma/migrations/20250429175856_update_expires_in/migration.sql
rename to prisma/migrations/20250430170529_preset_field/migration.sql
index 49754cd8..dcfaebc6 100644
--- a/prisma/migrations/20250429175856_update_expires_in/migration.sql
+++ b/prisma/migrations/20250430170529_preset_field/migration.sql
@@ -5,5 +5,6 @@
*/
-- AlterTable
-ALTER TABLE "LinkPreset" DROP COLUMN "expiresIn",
+ALTER TABLE "LinkPreset" ADD COLUMN "enableScreenshotProtection" BOOLEAN DEFAULT false,
+DROP COLUMN "expiresIn",
ADD COLUMN "expiresIn" JSONB;
diff --git a/prisma/schema/link.prisma b/prisma/schema/link.prisma
index a172f5c0..c66f6c7b 100644
--- a/prisma/schema/link.prisma
+++ b/prisma/schema/link.prisma
@@ -99,6 +99,7 @@ model LinkPreset {
enableDenyList Boolean? @default(false)
denyList String[]
expiresIn Json? // how many days from link creation until it expires in seconds {value: 604800, type: "natural | normal"}
+ enableScreenshotProtection Boolean? @default(false)
expiresAt DateTime?
enablePassword Boolean? @default(false)
password String?