@@ -8,16 +8,25 @@ import type { editor } from 'monaco-editor';
8
8
import { getOriginalLanguage , getSelectionRange } from '../../utils' ;
9
9
import { DefaultEditorConfig } from './config' ;
10
10
import { TextDrawer } from '../TextDrawer' ;
11
+ import { Empty } from 'antd' ;
11
12
12
13
interface CodeViewerProps {
13
14
path : string ;
14
15
content : string ;
15
16
defaultLine ?: number ;
16
17
ranges ?: SDK . SourceRange [ ] ;
17
18
editorConfig ?: editor . IStandaloneEditorConstructionOptions ;
19
+ emptyReason ?: string ;
18
20
}
19
21
20
- export const CodeViewer : React . FC < CodeViewerProps > = ( { content, ranges, path, defaultLine, editorConfig = { } } ) => {
22
+ export const CodeViewer : React . FC < CodeViewerProps > = ( {
23
+ content,
24
+ ranges,
25
+ path,
26
+ defaultLine,
27
+ editorConfig = { } ,
28
+ emptyReason,
29
+ } ) => {
21
30
const handleEditorDidMount : OnMount = ( editor , monaco ) => {
22
31
if ( isNumber ( defaultLine ) ) {
23
32
editor . revealLine ( defaultLine ) ;
@@ -36,7 +45,7 @@ export const CodeViewer: React.FC<CodeViewerProps> = ({ content, ranges, path, d
36
45
}
37
46
} ;
38
47
39
- return (
48
+ return content ? (
40
49
< Editor
41
50
theme = "vs-dark"
42
51
language = { getOriginalLanguage ( path ) }
@@ -46,6 +55,8 @@ export const CodeViewer: React.FC<CodeViewerProps> = ({ content, ranges, path, d
46
55
options = { { ...DefaultEditorConfig , ...editorConfig } }
47
56
onMount = { handleEditorDidMount }
48
57
/>
58
+ ) : (
59
+ < Empty description = { emptyReason } />
49
60
) ;
50
61
} ;
51
62
0 commit comments