@@ -12,6 +12,7 @@ import {
1212 isWorkspaceAudioPreviewPath ,
1313 isWorkspaceImagePreviewPath ,
1414 isWorkspaceVideoPreviewPath ,
15+ officePreviewKind ,
1516} from "@t3tools/shared/filePreview" ;
1617import {
1718 DEFAULT_TOKENIZE_MAX_LENGTH ,
@@ -75,6 +76,7 @@ import { AttachmentFilePreview } from "./AttachmentFilePreview";
7576import { AudioPreview } from "./AudioPreview" ;
7677import { BrowserDocumentFrame , isPdfPreviewFile } from "./BrowserDocumentFrame" ;
7778import { DelimitedTablePreview } from "./DelimitedTablePreview" ;
79+ import { OfficeFilePreview } from "./OfficeFilePreview" ;
7880import FileBrowserPanel from "./FileBrowserPanel" ;
7981import { FileBreadcrumbs } from "./FileBreadcrumbs" ;
8082import { breadcrumbPathOf , retainedBreadcrumbTrail , trailChildOf } from "./filePath" ;
@@ -251,6 +253,15 @@ function WorkspaceBrowserPreview(props: {
251253 </ div >
252254 ) ;
253255 }
256+ const officeKind = officePreviewKind ( { name : props . absolutePath } ) ;
257+ if ( officeKind )
258+ return (
259+ < OfficeFilePreview
260+ src = { `${ assetUrl . url } ${ revisionSuffix } ` }
261+ name = { props . title }
262+ kind = { officeKind }
263+ />
264+ ) ;
254265 return (
255266 < BrowserDocumentFrame
256267 src = { `${ assetUrl . url } ${ revisionSuffix } ` }
@@ -1004,6 +1015,7 @@ export default function FilePreviewPanel({
10041015 const isImage = relativePath !== null && ! isVideo && isWorkspaceImagePreviewPath ( relativePath ) ;
10051016 const isMedia = isImage || isVideo || isAudio ;
10061017 const isPdf = relativePath !== null && isPdfPreviewFile ( relativePath ) ;
1018+ const isOffice = relativePath !== null && officePreviewKind ( { name : relativePath } ) !== null ;
10071019 const isHtml = relativePath !== null && ! isPdf && isBrowserPreviewFile ( relativePath ) ;
10081020 const isHostFile =
10091021 attachment !== undefined || ( relativePath !== null && isAbsolutePath ( relativePath ) ) ;
@@ -1089,7 +1101,8 @@ export default function FilePreviewPanel({
10891101 file . data !== null &&
10901102 ! ( isMarkdown && renderMarkdown ) &&
10911103 ! ( tableDelimiter && renderTable ) &&
1092- ! renderBrowserFile ;
1104+ ! renderBrowserFile &&
1105+ ! isOffice ;
10931106 const rendered = isMarkdown ? renderMarkdown : tableDelimiter ? renderTable : renderBrowserFile ;
10941107 const setRenderedPreferred = isMarkdown
10951108 ? setRenderMarkdownPreferred
@@ -1126,7 +1139,7 @@ export default function FilePreviewPanel({
11261139 // Media and PDFs never show their contents, so re-reading them on every
11271140 // workspace mutation is waste. A folder named like one still re-reads, so
11281141 // it notices when the path becomes a file.
1129- ( isFolder || ( ! isMedia && ! isPdf ) ) &&
1142+ ( isFolder || ( ! isMedia && ! isPdf && ! isOffice ) ) &&
11301143 ! selectedFilePending ,
11311144 mutationId : workspaceMutationId ,
11321145 refresh : file . refresh ,
@@ -1337,7 +1350,7 @@ export default function FilePreviewPanel({
13371350 alt = { relativePath }
13381351 workspaceMutationId = { workspaceMutationId }
13391352 />
1340- ) : relativePath && renderBrowserFile && absolutePath ? (
1353+ ) : relativePath && ( renderBrowserFile || isOffice ) && absolutePath ? (
13411354 < WorkspaceBrowserPreview
13421355 key = { absolutePath }
13431356 environmentId = { environmentId }
@@ -1448,7 +1461,7 @@ export default function FilePreviewPanel({
14481461 selectedPathRevealId = { revealRequestId }
14491462 onOpenFile = { onOpenFile }
14501463 workspaceMutationId = { workspaceMutationId }
1451- { ...( previewPath && ! isMedia && ! isPdf
1464+ { ...( previewPath && ! isMedia && ! isPdf && ! isOffice
14521465 ? { onRefreshSelectedFile : file . refresh }
14531466 : { } ) }
14541467 />
0 commit comments