@@ -557,6 +557,26 @@ function initPreviewButtons() {
557557function openPreview ( filename , filetype ) {
558558 console . log ( 'Opening preview for:' , filename , filetype ) ;
559559
560+ // For non-previewable files, open directly in new tab
561+ const nonPreviewableTypes = [
562+ 'application/pdf' ,
563+ 'application/msword' ,
564+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ,
565+ 'application/vnd.ms-excel' ,
566+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ,
567+ 'application/vnd.ms-powerpoint' ,
568+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' ,
569+ 'application/zip' ,
570+ 'application/x-rar-compressed'
571+ ] ;
572+
573+ if ( nonPreviewableTypes . includes ( filetype ) ) {
574+ // Open in new tab for non-previewable files
575+ const downloadUrl = `/download/${ encodeURIComponent ( filename ) } ` ;
576+ window . open ( downloadUrl , '_blank' , 'noopener,noreferrer' ) ;
577+ return ;
578+ }
579+
560580 const modal = document . getElementById ( 'previewModal' ) ;
561581 const title = document . getElementById ( 'previewTitle' ) ;
562582 const content = document . getElementById ( 'previewContent' ) ;
@@ -580,11 +600,10 @@ function openPreview(filename, filetype) {
580600 // Determine preview method based on file type
581601 if ( filetype . startsWith ( 'image/' ) ) {
582602 previewImage ( filename , content ) ;
583- } else if ( filetype === 'application/pdf' ) {
584- previewPDF ( filename , content ) ;
585603 } else if ( filetype . startsWith ( 'text/' ) ) {
586604 previewText ( filename , content ) ;
587605 } else {
606+ // For other file types, show unsupported message
588607 content . innerHTML = `
589608 <div class="preview-unsupported">
590609 <p>Preview not available for this file type.</p>
0 commit comments