Skip to content

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

feat(content): add videoplayer component

Marc Seitz7f2b7d6f31c1
diff --git a/components/mdx/components/index.tsx b/components/mdx/components/index.tsx
index c77a4288..af49cc69 100644
--- a/components/mdx/components/index.tsx
+++ b/components/mdx/components/index.tsx
@@ -11,6 +11,7 @@ import { cn } from "@/lib/utils";
import { Table } from "./feature-table";
import { MDXImage } from "./mdx-image";
+import { VideoPlayer, YoutubePlayer } from "./video";
export const mdxComponents: MDXComponents = {
a: ({ children, ...props }) => {
@@ -98,5 +99,14 @@ export const mdxComponents: MDXComponents = {
return <Faq rows={rows} {...props} />;
},
+ Video: ({ src, ...props }) => {
+ if (!src || !src.startsWith("https://")) return null;
+
+ if (src.includes("assets.papermark.io")) {
+ return <VideoPlayer url={src} {...props} />;
+ }
+
+ return <YoutubePlayer url={src} {...props} />;
+ },
// any other components you want to use in your markdown
};
diff --git a/components/mdx/components/video.tsx b/components/mdx/components/video.tsx
new file mode 100644
index 00000000..30b97706
--- /dev/null
+++ b/components/mdx/components/video.tsx
@@ -0,0 +1,48 @@
+"use client";
+
+import React from "react";
+
+import ReactPlayer from "react-player/youtube";
+
+type VideoProps = {
+ url: string;
+};
+
+export const YoutubePlayer: React.FC<VideoProps> = ({ url }) => {
+ return (
+ <div className="mt-4 h-auto w-full">
+ <ReactPlayer
+ url={url}
+ className="aspect-video w-full"
+ width="100%"
+ height="100%"
+ controls
+ light
+ playing
+ config={{
+ embedOptions: {
+ host: "https://www.youtube-nocookie.com",
+ },
+ }}
+ />
+ </div>
+ );
+};
+
+export const VideoPlayer: React.FC<VideoProps> = ({ url }) => {
+ return (
+ <div className="mt-4 h-auto w-full">
+ <video
+ width="100%"
+ id="video1"
+ aria-hidden="true"
+ playsInline
+ muted
+ loop
+ controls
+ >
+ <source src={url} type="video/mp4" />
+ </video>
+ </div>
+ );
+};
diff --git a/package-lock.json b/package-lock.json
index cf418ad9..2d3d1ada 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -99,6 +99,7 @@
"react-notion-x": "^6.16.0",
"react-pdf": "^8.0.2",
"react-phone-number-input": "^3.4.3",
+ "react-player": "^2.16.0",
"react-textarea-autosize": "^8.5.3",
"react-zoom-pan-pinch": "^3.6.1",
"rehype-autolink-headings": "^7.1.0",
@@ -14222,6 +14223,11 @@
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg=="
},
+ "node_modules/load-script": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/load-script/-/load-script-1.0.0.tgz",
+ "integrity": "sha512-kPEjMFtZvwL9TaZo0uZ2ml+Ye9HUMmPwbYRJ324qF9tqMejwykJ5ggTyvzmrbBeapCAbk98BSbTeovHEEP1uCA=="
+ },
"node_modules/loader-runner": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz",
@@ -14845,6 +14851,11 @@
"url": "https://github.com/sindresorhus/mem?sponsor=1"
}
},
+ "node_modules/memoize-one": {
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz",
+ "integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q=="
+ },
"node_modules/merge-class-names": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/merge-class-names/-/merge-class-names-1.4.2.tgz",
@@ -18203,6 +18214,21 @@
"react-dom": ">=16.8"
}
},
+ "node_modules/react-player": {
+ "version": "2.16.0",
+ "resolved": "https://registry.npmjs.org/react-player/-/react-player-2.16.0.tgz",
+ "integrity": "sha512-mAIPHfioD7yxO0GNYVFD1303QFtI3lyyQZLY229UEAp/a10cSW+hPcakg0Keq8uWJxT2OiT/4Gt+Lc9bD6bJmQ==",
+ "dependencies": {
+ "deepmerge": "^4.0.0",
+ "load-script": "^1.0.0",
+ "memoize-one": "^5.1.1",
+ "prop-types": "^15.7.2",
+ "react-fast-compare": "^3.0.1"
+ },
+ "peerDependencies": {
+ "react": ">=16.6.0"
+ }
+ },
"node_modules/react-promise-suspense": {
"version": "0.3.4",
"resolved": "https://registry.npmjs.org/react-promise-suspense/-/react-promise-suspense-0.3.4.tgz",
diff --git a/package.json b/package.json
index 48f02c70..7d3b77c6 100644
--- a/package.json
+++ b/package.json
@@ -108,6 +108,7 @@
"react-notion-x": "^6.16.0",
"react-pdf": "^8.0.2",
"react-phone-number-input": "^3.4.3",
+ "react-player": "^2.16.0",
"react-textarea-autosize": "^8.5.3",
"react-zoom-pan-pinch": "^3.6.1",
"rehype-autolink-headings": "^7.1.0",