@@ -14,9 +14,10 @@ interface MonacoDiffEditorProps {
1414 onChange ?: ( value : string ) => void ;
1515 onScroll ?: ( scrollInfo : { scrollTop : number ; scrollHeight : number ; clientHeight : number } ) => void ;
1616 fontFamily ?: string ;
17+ fontSize ?: number ;
1718}
1819
19- const MonacoDiffEditor : React . FC < MonacoDiffEditorProps > = ( { oldText, newText, language, renderMode = 'side-by-side' , readOnly = false , onChange, onScroll, fontFamily } ) => {
20+ const MonacoDiffEditor : React . FC < MonacoDiffEditorProps > = ( { oldText, newText, language, renderMode = 'side-by-side' , readOnly = false , onChange, onScroll, fontFamily, fontSize } ) => {
2021 const editorRef = useRef < HTMLDivElement > ( null ) ;
2122 const editorInstanceRef = useRef < any > ( null ) ;
2223 const { theme } = useTheme ( ) ;
@@ -27,6 +28,13 @@ const MonacoDiffEditor: React.FC<MonacoDiffEditorProps> = ({ oldText, newText, l
2728 const candidate = ( fontFamily ?? '' ) . trim ( ) ;
2829 return candidate || DEFAULT_SETTINGS . editorFontFamily ;
2930 } , [ fontFamily ] ) ;
31+ const computedFontSize = useMemo ( ( ) => {
32+ const candidate = typeof fontSize === 'number' ? fontSize : Number ( fontSize ) ;
33+ if ( Number . isFinite ( candidate ) && candidate > 0 ) {
34+ return Math . min ( Math . max ( candidate , 8 ) , 64 ) ;
35+ }
36+ return DEFAULT_SETTINGS . editorFontSize ;
37+ } , [ fontSize ] ) ;
3038
3139 const disposeListeners = useCallback ( ( ) => {
3240 if ( changeListenerRef . current ) {
@@ -54,7 +62,7 @@ const MonacoDiffEditor: React.FC<MonacoDiffEditorProps> = ({ oldText, newText, l
5462 originalEditable : false ,
5563 readOnly,
5664 automaticLayout : true ,
57- fontSize : 12 ,
65+ fontSize : computedFontSize ,
5866 fontFamily : computedFontFamily ,
5967 wordWrap : 'on' ,
6068 renderSideBySide : renderMode !== 'inline' ,
@@ -69,6 +77,7 @@ const MonacoDiffEditor: React.FC<MonacoDiffEditorProps> = ({ oldText, newText, l
6977 renderSideBySide : renderMode !== 'inline' ,
7078 diffWordWrap : 'on' ,
7179 fontFamily : computedFontFamily ,
80+ fontSize : computedFontSize ,
7281 } ) ;
7382
7483 monaco . editor . setTheme ( theme === 'dark' ? 'vs-dark' : 'vs' ) ;
@@ -110,13 +119,13 @@ const MonacoDiffEditor: React.FC<MonacoDiffEditorProps> = ({ oldText, newText, l
110119 return ( ) => {
111120 isCancelled = true ;
112121 } ;
113- } , [ oldText , newText , language , theme , renderMode , readOnly , onChange , onScroll , disposeListeners , computedFontFamily ] ) ;
122+ } , [ oldText , newText , language , theme , renderMode , readOnly , onChange , onScroll , disposeListeners , computedFontFamily , computedFontSize ] ) ;
114123
115124 useEffect ( ( ) => {
116125 if ( editorInstanceRef . current ) {
117- editorInstanceRef . current . updateOptions ( { fontFamily : computedFontFamily } ) ;
126+ editorInstanceRef . current . updateOptions ( { fontFamily : computedFontFamily , fontSize : computedFontSize } ) ;
118127 }
119- } , [ computedFontFamily ] ) ;
128+ } , [ computedFontFamily , computedFontSize ] ) ;
120129
121130 // Final cleanup on unmount
122131 useEffect ( ( ) => {
0 commit comments