Skip to content

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

feat:updates

Iuliia Shnai16ac3ea88a4a
diff --git a/components/datarooms/settings/introduction-settings.tsx b/components/datarooms/settings/introduction-settings.tsx
index f17ec60a..30f8d55a 100644
--- a/components/datarooms/settings/introduction-settings.tsx
+++ b/components/datarooms/settings/introduction-settings.tsx
@@ -246,16 +246,7 @@ function generateIntroductionContent(
});
// Placeholder for navigation screenshot
- content.push({
- type: "paragraph",
- content: [
- {
- type: "text",
- text: "[Add a screenshot of your data room navigation here]",
- marks: [{ type: "italic" }],
- },
- ],
- });
+
// Q&A and Conversations section
content.push({
@@ -323,16 +314,7 @@ function generateIntroductionContent(
});
// Placeholder for conversations screenshot
- content.push({
- type: "paragraph",
- content: [
- {
- type: "text",
- text: "[Add a screenshot of the chat/conversation feature here]",
- marks: [{ type: "italic" }],
- },
- ],
- });
+
// Need Help section
content.push({
@@ -472,6 +454,32 @@ function renderContent(content: any): React.ReactNode {
className="my-3 h-auto max-w-full rounded-md"
/>
);
+ } else if (node.type === "youtube") {
+ // Extract video ID from the src URL
+ const src = node.attrs?.src || "";
+ let videoId = "";
+
+ // Handle different YouTube URL formats
+ const youtubeMatch = src.match(
+ /(?:youtube\.com\/(?:embed\/|watch\?v=)|youtu\.be\/)([^?&]+)/,
+ );
+ if (youtubeMatch) {
+ videoId = youtubeMatch[1];
+ }
+
+ if (!videoId) return null;
+
+ return (
+ <div key={index} className="my-4 aspect-video w-full">
+ <iframe
+ src={`https://www.youtube-nocookie.com/embed/${videoId}`}
+ title="YouTube video"
+ className="h-full w-full rounded-lg"
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
+ allowFullScreen
+ />
+ </div>
+ );
}
return null;
});
@@ -715,7 +723,7 @@ export default function IntroductionSettings({
{/* Preview Dialog */}
<Dialog open={showPreview} onOpenChange={setShowPreview}>
- <DialogContent className="max-h-[90vh] w-[95vw] max-w-3xl overflow-hidden border-0 p-0 shadow-2xl sm:rounded-2xl">
+ <DialogContent className="max-h-[85vh] max-w-2xl overflow-hidden border-0 p-0 shadow-2xl sm:max-w-xl sm:rounded-2xl md:max-w-2xl">
<DialogHeader className="border-b border-gray-100 bg-gray-50 px-4 py-6 dark:border-gray-800 dark:bg-gray-900 sm:px-6">
<p className="mb-1 text-xs text-muted-foreground">
This is preview
diff --git a/components/ui/rich-text-editor.tsx b/components/ui/rich-text-editor.tsx
index 28ab909c..99f86755 100644
--- a/components/ui/rich-text-editor.tsx
+++ b/components/ui/rich-text-editor.tsx
@@ -1,9 +1,10 @@
"use client";
-import { useCallback } from "react";
+import { useCallback, useState } from "react";
import Image from "@tiptap/extension-image";
import Placeholder from "@tiptap/extension-placeholder";
+import Youtube from "@tiptap/extension-youtube";
import { EditorContent, useEditor } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
import {
@@ -17,8 +18,19 @@ import {
Quote,
Redo,
Undo,
+ Youtube as YoutubeIcon,
} from "lucide-react";
+import {
+ Dialog,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+
import { Button } from "@/components/ui/button";
interface RichTextEditorProps {
@@ -34,6 +46,9 @@ export function RichTextEditor({
placeholder = "Start typing...",
onImageUpload,
}: RichTextEditorProps) {
+ const [youtubeDialogOpen, setYoutubeDialogOpen] = useState(false);
+ const [youtubeUrl, setYoutubeUrl] = useState("");
+
const editor = useEditor({
extensions: [
StarterKit,
@@ -44,6 +59,13 @@ export function RichTextEditor({
class: "rounded-lg max-w-full h-auto",
},
}),
+ Youtube.configure({
+ controls: true,
+ nocookie: true,
+ HTMLAttributes: {
+ class: "rounded-lg w-full aspect-video",
+ },
+ }),
Placeholder.configure({
placeholder,
}),
@@ -153,6 +175,17 @@ export function RichTextEditor({
[editor, onImageUpload],
);
+ const addYoutubeVideo = useCallback(() => {
+ if (!editor || !youtubeUrl) return;
+
+ editor.commands.setYoutubeVideo({
+ src: youtubeUrl,
+ });
+
+ setYoutubeUrl("");
+ setYoutubeDialogOpen(false);
+ }, [editor, youtubeUrl]);
+
if (!editor) {
return null;
}
@@ -238,6 +271,14 @@ export function RichTextEditor({
</Button>
</>
)}
+ <Button
+ variant="ghost"
+ size="sm"
+ type="button"
+ onClick={() => setYoutubeDialogOpen(true)}
+ >
+ <YoutubeIcon className="h-4 w-4" />
+ </Button>
<div className="mx-1 h-6 w-px bg-border" />
<Button
variant="ghost"
@@ -266,6 +307,47 @@ export function RichTextEditor({
className="prose prose-sm max-w-none focus:outline-none [&_.ProseMirror]:min-h-[150px] [&_.ProseMirror]:focus:outline-none"
/>
</div>
+
+ {/* YouTube Dialog */}
+ <Dialog open={youtubeDialogOpen} onOpenChange={setYoutubeDialogOpen}>
+ <DialogContent className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle>Add YouTube Video</DialogTitle>
+ </DialogHeader>
+ <div className="space-y-4 py-4">
+ <div className="space-y-2">
+ <Label htmlFor="youtube-url">YouTube URL</Label>
+ <Input
+ id="youtube-url"
+ placeholder="https://www.youtube.com/watch?v=..."
+ value={youtubeUrl}
+ onChange={(e) => setYoutubeUrl(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ addYoutubeVideo();
+ }
+ }}
+ />
+ <p className="text-xs text-muted-foreground">
+ Paste a YouTube video URL (e.g., youtube.com/watch?v=...,
+ youtu.be/...)
+ </p>
+ </div>
+ </div>
+ <DialogFooter>
+ <Button
+ variant="outline"
+ onClick={() => setYoutubeDialogOpen(false)}
+ >
+ Cancel
+ </Button>
+ <Button onClick={addYoutubeVideo} disabled={!youtubeUrl}>
+ Add Video
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
</div>
);
}
diff --git a/components/view/dataroom/introduction-modal.tsx b/components/view/dataroom/introduction-modal.tsx
index 06765620..2c518482 100644
--- a/components/view/dataroom/introduction-modal.tsx
+++ b/components/view/dataroom/introduction-modal.tsx
@@ -1,6 +1,12 @@
"use client";
-import { useEffect, useState } from "react";
+import React, {
+ createContext,
+ useContext,
+ useEffect,
+ useState,
+ useCallback,
+} from "react";
import { InfoIcon } from "lucide-react";
@@ -29,6 +35,51 @@ interface IntroductionModalProps {
viewerId?: string;
}
+// Context to share modal state
+interface IntroductionContextType {
+ openIntroduction: () => void;
+ hasIntroduction: boolean;
+ hasSeen: boolean;
+}
+
+const IntroductionContext = createContext<IntroductionContextType>({
+ openIntroduction: () => {},
+ hasIntroduction: false,
+ hasSeen: false,
+});
+
+export const useIntroduction = () => useContext(IntroductionContext);
+
+// Info button component to be placed inline (e.g., next to dataroom name)
+export function IntroductionInfoButton() {
+ const { openIntroduction, hasIntroduction, hasSeen } = useIntroduction();
+
+ if (!hasIntroduction) return null;
+
+ return (
+ <TooltipProvider delayDuration={0}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <button
+ onClick={openIntroduction}
+ className={`inline-flex items-center justify-center rounded-full p-1.5 transition-colors ${
+ hasSeen
+ ? "text-muted-foreground hover:bg-muted hover:text-foreground"
+ : "border-2 border-gray-900 text-gray-900 hover:bg-gray-100 dark:border-white dark:text-white dark:hover:bg-gray-800"
+ }`}
+ aria-label="View introduction"
+ >
+ <InfoIcon className="h-5 w-5" />
+ </button>
+ </TooltipTrigger>
+ <TooltipContent side="left">
+ <p>View introduction</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ );
+}
+
// Render TipTap JSON content
function renderContent(content: any): React.ReactNode {
if (!content || !content.content) return null;
@@ -144,93 +195,123 @@ function renderContent(content: any): React.ReactNode {
className="my-3 h-auto max-w-full rounded-md"
/>
);
+ } else if (node.type === "youtube") {
+ // Extract video ID from the src URL
+ const src = node.attrs?.src || "";
+ let videoId = "";
+
+ // Handle different YouTube URL formats
+ const youtubeMatch = src.match(
+ /(?:youtube\.com\/(?:embed\/|watch\?v=)|youtu\.be\/)([^?&]+)/,
+ );
+ if (youtubeMatch) {
+ videoId = youtubeMatch[1];
+ }
+
+ if (!videoId) return null;
+
+ return (
+ <div key={index} className="my-4 aspect-video w-full">
+ <iframe
+ src={`https://www.youtube-nocookie.com/embed/${videoId}`}
+ title="YouTube video"
+ className="h-full w-full rounded-lg"
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
+ allowFullScreen
+ />
+ </div>
+ );
}
return null;
});
}
-export function IntroductionModal({
+interface IntroductionProviderProps extends IntroductionModalProps {
+ children: React.ReactNode;
+}
+
+export function IntroductionProvider({
dataroom,
viewerId,
-}: IntroductionModalProps) {
+ children,
+}: IntroductionProviderProps) {
const [isOpen, setIsOpen] = useState(false);
+ const [hasSeen, setHasSeen] = useState(true); // Default to true, will be updated on mount
const storageKey = `dataroom-intro-seen-${dataroom.id}${viewerId ? `-${viewerId}` : ""}`;
+ const content = dataroom.introductionContent as any;
+ const hasContent =
+ dataroom.introductionEnabled &&
+ content?.content &&
+ content.content.length > 0;
+
useEffect(() => {
// Check if introduction is enabled and has content
- if (!dataroom.introductionEnabled || !dataroom.introductionContent) {
+ if (!hasContent) {
return;
}
- // Check if user has already seen the introduction - show only first time
+ // Check if user has already seen the introduction
const seen = localStorage.getItem(storageKey);
+ setHasSeen(!!seen);
+
+ // Show modal only first time
if (!seen) {
setIsOpen(true);
}
- }, [dataroom.introductionEnabled, dataroom.introductionContent, storageKey]);
+ }, [hasContent, storageKey]);
const handleClose = () => {
setIsOpen(false);
localStorage.setItem(storageKey, "true");
+ setHasSeen(true);
};
- const handleReopen = () => {
+ const openIntroduction = useCallback(() => {
setIsOpen(true);
- };
-
- // Don't render anything if introduction is not enabled or has no content
- if (!dataroom.introductionEnabled || !dataroom.introductionContent) {
- return null;
- }
-
- const content = dataroom.introductionContent as any;
- const hasContent = content?.content && content.content.length > 0;
-
- if (!hasContent) {
- return null;
- }
+ }, []);
return (
- <>
- {/* Info icon to reopen introduction - always visible */}
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <button
- onClick={handleReopen}
- className="fixed right-4 top-20 z-50 flex h-10 w-10 items-center justify-center rounded-full bg-white/90 shadow-lg ring-1 ring-gray-200 backdrop-blur-sm transition-all hover:bg-white hover:shadow-xl dark:bg-gray-800/90 dark:ring-gray-700 dark:hover:bg-gray-800"
- aria-label="View introduction"
- >
- <InfoIcon className="h-5 w-5 text-gray-600 dark:text-gray-300" />
- </button>
- </TooltipTrigger>
- <TooltipContent side="left">
- <p>View introduction</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
+ <IntroductionContext.Provider
+ value={{ openIntroduction, hasIntroduction: hasContent, hasSeen }}
+ >
+ {children}
{/* Introduction Modal */}
- <Dialog open={isOpen} onOpenChange={setIsOpen}>
- <DialogContent className="max-h-[85vh] max-w-2xl overflow-hidden border-0 p-0 shadow-2xl sm:max-w-xl sm:rounded-2xl md:max-w-2xl">
- <DialogHeader className="border-b border-gray-100 bg-gray-50 px-6 py-6 dark:border-gray-800 dark:bg-gray-900">
- <DialogTitle className="text-xl font-semibold">
- Welcome to {dataroom.name || "Data Room"}
- </DialogTitle>
- </DialogHeader>
- <ScrollArea className="max-h-[60vh] px-6 py-5">
- <div className="prose prose-sm max-w-none dark:prose-invert">
- {renderContent(content)}
+ {hasContent && (
+ <Dialog open={isOpen} onOpenChange={setIsOpen}>
+ <DialogContent className="max-h-[85vh] max-w-2xl overflow-hidden border-0 p-0 shadow-2xl sm:max-w-xl sm:rounded-2xl md:max-w-2xl">
+ <DialogHeader className="border-b border-gray-100 bg-gray-50 px-6 py-6 dark:border-gray-800 dark:bg-gray-900">
+ <DialogTitle className="text-xl font-semibold">
+ Welcome to {dataroom.name || "Data Room"}
+ </DialogTitle>
+ </DialogHeader>
+ <ScrollArea className="max-h-[60vh] px-6 py-5">
+ <div className="prose prose-sm max-w-none dark:prose-invert">
+ {renderContent(content)}
+ </div>
+ </ScrollArea>
+ <div className="flex justify-end border-t border-gray-100 bg-gray-50 px-6 py-4 dark:border-gray-800 dark:bg-gray-900">
+ <Button onClick={handleClose} size="lg">
+ Continue to Data Room
+ </Button>
</div>
- </ScrollArea>
- <div className="flex justify-end border-t border-gray-100 bg-gray-50 px-6 py-4 dark:border-gray-800 dark:bg-gray-900">
- <Button onClick={handleClose} size="lg">
- Continue to Data Room
- </Button>
- </div>
- </DialogContent>
- </Dialog>
- </>
+ </DialogContent>
+ </Dialog>
+ )}
+ </IntroductionContext.Provider>
+ );
+}
+
+// Backwards compatible export
+export function IntroductionModal({
+ dataroom,
+ viewerId,
+}: IntroductionModalProps) {
+ return (
+ <IntroductionProvider dataroom={dataroom} viewerId={viewerId}>
+ {null}
+ </IntroductionProvider>
);
}
diff --git a/components/view/viewer/dataroom-viewer.tsx b/components/view/viewer/dataroom-viewer.tsx
index ba5a6346..c7345408 100644
--- a/components/view/viewer/dataroom-viewer.tsx
+++ b/components/view/viewer/dataroom-viewer.tsx
@@ -48,7 +48,10 @@ import DocumentCard from "../dataroom/document-card";
import { DocumentUploadModal } from "../dataroom/document-upload-modal";
import FolderCard from "../dataroom/folder-card";
import IndexFileDialog from "../dataroom/index-file-dialog";
-import { IntroductionModal } from "../dataroom/introduction-modal";
+import {
+ IntroductionInfoButton,
+ IntroductionProvider,
+} from "../dataroom/introduction-modal";
import DataroomNav from "../dataroom/nav-dataroom";
const ViewerBreadcrumbItem = ({
@@ -385,16 +388,17 @@ export default function DataroomViewer({
}));
return (
- <ViewerChatProvider
- enabled={viewData.agentsEnabled}
- dataroomId={dataroom?.id}
- dataroomName={viewData.dataroomName}
- linkId={linkId}
- viewId={viewId}
- viewerId={viewerId}
- documents={documentsForChat}
- folders={folders}
- >
+ <IntroductionProvider dataroom={dataroom} viewerId={viewerId}>
+ <ViewerChatProvider
+ enabled={viewData.agentsEnabled}
+ dataroomId={dataroom?.id}
+ dataroomName={viewData.dataroomName}
+ linkId={linkId}
+ viewId={viewId}
+ viewerId={viewerId}
+ documents={documentsForChat}
+ folders={folders}
+ >
<DataroomNav
brand={brand}
linkId={linkId}
@@ -500,6 +504,7 @@ export default function DataroomViewer({
</Breadcrumb>
<div className="flex items-center gap-x-2">
+ <IntroductionInfoButton />
<SearchBoxPersisted inputClassName="h-9" />
{enableIndexFile && viewId && viewerId && (
<IndexFileDialog
@@ -562,9 +567,7 @@ export default function DataroomViewer({
{/* AI Chat Components */}
<ViewerChatPanel />
<ViewerChatToggle />
-
- {/* Introduction Modal */}
- <IntroductionModal dataroom={dataroom} viewerId={viewerId} />
- </ViewerChatProvider>
+ </ViewerChatProvider>
+ </IntroductionProvider>
);
}
diff --git a/package-lock.json b/package-lock.json
index 3156f73d..6136b603 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -62,6 +62,7 @@
"@teamhanko/passkeys-next-auth-provider": "^0.3.1",
"@tiptap/extension-image": "^3.6.2",
"@tiptap/extension-placeholder": "^3.6.2",
+ "@tiptap/extension-youtube": "^3.19.0",
"@tiptap/react": "^3.6.2",
"@tiptap/starter-kit": "^3.6.2",
"@tremor/react": "^3.18.7",
@@ -7392,9 +7393,9 @@
}
},
"node_modules/@tiptap/core": {
- "version": "3.6.2",
- "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.6.2.tgz",
- "integrity": "sha512-XKZYrCVFsyQGF6dXQR73YR222l/76wkKfZ+2/4LCrem5qtcOarmv5pYxjUBG8mRuBPskTTBImSFTeQltJIUNCg==",
+ "version": "3.19.0",
+ "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.19.0.tgz",
+ "integrity": "sha512-bpqELwPW+DG8gWiD8iiFtSl4vIBooG5uVJod92Qxn3rA9nFatyXRr4kNbMJmOZ66ezUvmCjXVe/5/G4i5cyzKA==",
"license": "MIT",
"peer": true,
"funding": {
@@ -7402,7 +7403,7 @@
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/pm": "^3.6.2"
+ "@tiptap/pm": "^3.19.0"
}
},
"node_modules/@tiptap/extension-blockquote": {
@@ -7746,6 +7747,19 @@
"@tiptap/core": "^3.6.2"
}
},
+ "node_modules/@tiptap/extension-youtube": {
+ "version": "3.19.0",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-youtube/-/extension-youtube-3.19.0.tgz",
+ "integrity": "sha512-/3Z/jw9VbD3WrS1cOcxKUN0oMVnX9NVSekVG4uJHZYs5LhG2tbmUkBYNzj4oJcZcuJ4WPTD1EaAVEgNVffaoJg==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/ueberdosis"
+ },
+ "peerDependencies": {
+ "@tiptap/core": "^3.19.0"
+ }
+ },
"node_modules/@tiptap/extensions": {
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/@tiptap/extensions/-/extensions-3.6.2.tgz",
@@ -7762,9 +7776,9 @@
}
},
"node_modules/@tiptap/pm": {
- "version": "3.6.2",
- "resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.6.2.tgz",
- "integrity": "sha512-g+NXjqjbj6NfHOMl22uNWVYIu8oCq7RFfbnpohPMsSKJLaHYE8mJR++7T6P5R9FoqhIFdwizg1jTpwRU5CHqXQ==",
+ "version": "3.19.0",
+ "resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.19.0.tgz",
+ "integrity": "sha512-789zcnM4a8OWzvbD2DL31d0wbSm9BVeO/R7PLQwLIGysDI3qzrcclyZ8yhqOEVuvPitRRwYLq+mY14jz7kY4cw==",
"license": "MIT",
"peer": true,
"dependencies": {
diff --git a/package.json b/package.json
index a19ad07c..92807caa 100644
--- a/package.json
+++ b/package.json
@@ -73,6 +73,7 @@
"@teamhanko/passkeys-next-auth-provider": "^0.3.1",
"@tiptap/extension-image": "^3.6.2",
"@tiptap/extension-placeholder": "^3.6.2",
+ "@tiptap/extension-youtube": "^3.19.0",
"@tiptap/react": "^3.6.2",
"@tiptap/starter-kit": "^3.6.2",
"@tremor/react": "^3.18.7",