@@ -13,15 +13,15 @@ import { LabIcon, closeIcon, downloadIcon } from '@jupyterlab/ui-components';
1313
1414/**
1515 * File type icons mapping function. We currently implement four common file types:
16- * 1. Image files (PNG, JPEG/JPG) (binary)
16+ * 1. Image files (PNG, JPEG/JPG, WEBP ) (binary)
1717 * 2. CSV/TSV files (text)
1818 * @param fileName - the name of the file to determine the icon for.
1919 * @param fileType - the MIME type of the file to determine the icon for.
2020 * @returns A LabIcon representing the file type icon.
2121 */
2222const getFileIcon = ( fileName : string , fileType : string ) : LabIcon => {
2323 const extension = fileName . split ( '.' ) . pop ( ) ?. toLowerCase ( ) || '' ;
24- if ( fileType . startsWith ( 'image/' ) || [ 'png' , 'jpg' , 'jpeg' ] . includes ( extension ) ) {
24+ if ( fileType . startsWith ( 'image/' ) || [ 'png' , 'jpg' , 'jpeg' , 'webp' ] . includes ( extension ) ) {
2525 return EverywhereIcons . imageIcon ;
2626 }
2727 if (
@@ -36,14 +36,20 @@ const getFileIcon = (fileName: string, fileType: string): LabIcon => {
3636} ;
3737
3838/**
39- * Checks if the file type is supported (PNG, JPG/JPEG, or CSV/TSV).
39+ * Checks if the file type is supported (PNG, JPG/JPEG, WEBP, or CSV/TSV).
4040 * @param file - The file to check
4141 * @returns True if the file type is supported, false otherwise.
4242 */
4343const isSupportedFileType = ( file : File ) : boolean => {
44- const supportedMimeTypes = [ 'image/png' , 'image/jpeg' , 'text/csv' , 'text/tab-separated-values' ] ;
44+ const supportedMimeTypes = [
45+ 'image/png' ,
46+ 'image/jpeg' ,
47+ 'image/webp' ,
48+ 'text/csv' ,
49+ 'text/tab-separated-values'
50+ ] ;
4551 const extension = file . name . split ( '.' ) . pop ( ) ?. toLowerCase ( ) || '' ;
46- const supportedExtensions = [ 'png' , 'jpg' , 'jpeg' , 'csv' , 'tsv' ] ;
52+ const supportedExtensions = [ 'png' , 'jpg' , 'jpeg' , 'webp' , ' csv', 'tsv' ] ;
4753 return supportedMimeTypes . includes ( file . type ) || supportedExtensions . includes ( extension ) ;
4854} ;
4955
@@ -77,7 +83,7 @@ const FileUploader = React.forwardRef<IFileUploaderRef, IFileUploaderProps>((pro
7783 if ( supportedFiles . length === 0 ) {
7884 await showErrorMessage (
7985 'Unsupported file type' ,
80- 'Please upload only PNG, JPG/JPEG, or CSV/TSV files.'
86+ 'Please upload only PNG, JPG/JPEG, WEBP, or CSV/TSV files.'
8187 ) ;
8288 return ;
8389 }
@@ -137,7 +143,7 @@ const FileUploader = React.forwardRef<IFileUploaderRef, IFileUploaderProps>((pro
137143 multiple
138144 onChange = { handleInputChange }
139145 style = { { display : 'none' } }
140- accept = ".png,.jpg,.jpeg,.csv,.tsv,image/png,image/jpeg,text/csv,text/tab-separated-values"
146+ accept = ".png,.jpg,.jpeg,.webp,. csv,.tsv,image/png,image/jpeg,image/webp ,text/csv,text/tab-separated-values"
141147 />
142148 ) ;
143149} ) ;
@@ -247,6 +253,9 @@ function FilesApp(props: IFilesAppProps) {
247253 if ( ext === 'jpg' || ext === 'jpeg' ) {
248254 return 'image/jpeg' ;
249255 }
256+ if ( ext === 'webp' ) {
257+ return 'image/webp' ;
258+ }
250259 if ( ext === 'csv' ) {
251260 return 'text/csv' ;
252261 }
0 commit comments