@@ -26,6 +26,30 @@ interface DocumentEditorProps {
2626 formatTrigger : number ;
2727}
2828
29+ const PREVIEWABLE_LANGUAGES = new Set < string > ( [
30+ 'markdown' ,
31+ 'html' ,
32+ 'pdf' ,
33+ 'application/pdf' ,
34+ 'image' ,
35+ 'png' ,
36+ 'jpg' ,
37+ 'jpeg' ,
38+ 'gif' ,
39+ 'bmp' ,
40+ 'webp' ,
41+ 'svg' ,
42+ 'svg+xml' ,
43+ 'image/png' ,
44+ 'image/jpg' ,
45+ 'image/jpeg' ,
46+ 'image/gif' ,
47+ 'image/webp' ,
48+ 'image/bmp' ,
49+ 'image/svg' ,
50+ 'image/svg+xml' ,
51+ ] ) ;
52+
2953const resolveDefaultViewMode = ( mode : ViewMode | null | undefined , languageHint : string | null | undefined ) : ViewMode => {
3054 if ( mode ) return mode ;
3155 const normalizedHint = languageHint ?. toLowerCase ( ) ;
@@ -357,7 +381,7 @@ const DocumentEditor: React.FC<DocumentEditorProps> = ({ documentNode, onSave, o
357381 }
358382 setRefinedContent ( null ) ;
359383 } ;
360-
384+
361385 const handleCopy = async ( ) => {
362386 if ( ! content . trim ( ) ) return ;
363387 await navigator . clipboard . writeText ( content ) ;
@@ -367,10 +391,11 @@ const DocumentEditor: React.FC<DocumentEditorProps> = ({ documentNode, onSave, o
367391 } ;
368392
369393 const language = documentNode . language_hint || 'plaintext' ;
370- const supportsAiTools = [ 'markdown' , 'plaintext' ] . includes ( language ) ;
371- const supportsPreview = [ 'markdown' , 'html' , 'pdf' ] . includes ( language ) ;
372- const supportsFormatting = [ 'javascript' , 'typescript' , 'json' , 'html' , 'css' , 'xml' , 'yaml' ] . includes ( language ) ;
373- const isPythonDocument = typeof window !== 'undefined' && ! ! window . electronAPI && ( language === 'python' ) ;
394+ const normalizedLanguage = language . toLowerCase ( ) ;
395+ const supportsAiTools = [ 'markdown' , 'plaintext' ] . includes ( normalizedLanguage ) ;
396+ const supportsPreview = PREVIEWABLE_LANGUAGES . has ( normalizedLanguage ) ;
397+ const supportsFormatting = [ 'javascript' , 'typescript' , 'json' , 'html' , 'css' , 'xml' , 'yaml' ] . includes ( normalizedLanguage ) ;
398+ const isPythonDocument = typeof window !== 'undefined' && ! ! window . electronAPI && ( normalizedLanguage === 'python' ) ;
374399 const pythonDefaults = useMemo ( ( ) => ( {
375400 ...settings . pythonDefaults ,
376401 workingDirectory : settings . pythonWorkingDirectory ?? settings . pythonDefaults . workingDirectory ?? null ,
0 commit comments