File tree Expand file tree Collapse file tree
packages/web/src/components/embed Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { EmbedImage } from "./variants/embed-image";
55import { EmbedMarkdown } from "./variants/embed-markdown" ;
66import { EmbedText } from "./variants/embed-text" ;
77import { EmbedVideo } from "./variants/embed-video" ;
8+ import { EmbedDocument } from "./variants/embed-document" ;
89
910interface EmbedProps {
1011 data : Embeddable ;
@@ -18,6 +19,11 @@ export const Embed: FC<EmbedProps> = ({ data }) => {
1819 const isImage = EmbedImage . embeddable ( data ) ;
1920 const isVideo = EmbedVideo . embeddable ( data ) ;
2021 const isMarkdown = EmbedMarkdown . embeddable ( data ) ;
22+ const isDocument = EmbedDocument . embeddable ( data ) ;
23+
24+ if ( isDocument ) {
25+ return < EmbedDocument file = { data } /> ;
26+ }
2127
2228 if ( isMarkdown ) {
2329 return < EmbedMarkdown data = { data } /> ;
Original file line number Diff line number Diff line change 1+ import clsx from "clsx" ;
2+ import { BASE_EMBED_CLASSES , MAX_HEIGHT } from "../embed" ;
3+ import type { Embeddable } from "../embeddable" ;
4+
5+ export const EmbedDocument = ( { file } : { file : Embeddable } ) => {
6+ const classes = clsx ( "outline-none h-[70vh] p-4" , BASE_EMBED_CLASSES , MAX_HEIGHT ) ;
7+
8+ return (
9+ < object data = { file . paths . direct } type = "application/pdf" aria-label = { file . displayName } className = { classes } >
10+ This browser does not support PDFs. You can download the file{ " " }
11+ < a className = "text-primary" href = { file . paths . direct } target = "_blank" rel = "noreferrer" >
12+ here
13+ </ a >
14+ .
15+ </ object >
16+ ) ;
17+ } ;
18+
19+ EmbedDocument . embeddable = ( data : Embeddable ) => {
20+ switch ( data . type ) {
21+ case "application/pdf" : {
22+ return true ;
23+ }
24+ default : {
25+ return false ;
26+ }
27+ }
28+ } ;
You can’t perform that action at this time.
0 commit comments