1212
1313import React , { useMemo , memo , useRef , useCallback , useState } from 'react' ;
1414import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' ;
15- import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism' ;
1615import { diffLines , Change } from 'diff' ;
1716import { getPrismLanguage } from '@/infrastructure/language-detection' ;
17+ import { useTheme } from '@/infrastructure/theme' ;
1818import { createLogger } from '@/shared/utils/logger' ;
19+ import { buildCodePreviewPrismStyle , CODE_PREVIEW_FONT_FAMILY } from './codePreviewPrismTheme' ;
1920import './InlineDiffPreview.scss' ;
2021
2122const log = createLogger ( 'InlineDiffPreview' ) ;
@@ -168,29 +169,6 @@ function applyContextCollapsing(diffLines: DiffLine[], contextLines: number): Di
168169 return result ;
169170}
170171
171- /**
172- * Custom theme styles (kept in sync with CodePreview).
173- */
174- const customStyle = {
175- ...vscDarkPlus ,
176- 'pre[class*="language-"]' : {
177- ...vscDarkPlus [ 'pre[class*="language-"]' ] ,
178- margin : 0 ,
179- padding : 0 ,
180- background : 'transparent' ,
181- fontSize : '12px' ,
182- lineHeight : '1.6' ,
183- fontFamily : "'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace" ,
184- } ,
185- 'code[class*="language-"]' : {
186- ...vscDarkPlus [ 'code[class*="language-"]' ] ,
187- background : 'transparent' ,
188- fontSize : '12px' ,
189- lineHeight : '1.6' ,
190- fontFamily : "'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace" ,
191- } ,
192- } ;
193-
194172/**
195173 * InlineDiffPreview component.
196174 */
@@ -207,6 +185,9 @@ export const InlineDiffPreview: React.FC<InlineDiffPreviewProps> = memo(({
207185 contextLines = 3 ,
208186 onLineClick,
209187} ) => {
188+ const { isLight } = useTheme ( ) ;
189+ const prismStyle = useMemo ( ( ) => buildCodePreviewPrismStyle ( isLight ) , [ isLight ] ) ;
190+
210191 const containerRef = useRef < HTMLDivElement > ( null ) ;
211192 const [ highlightedLine , setHighlightedLine ] = useState < number | null > ( null ) ;
212193
@@ -285,7 +266,7 @@ export const InlineDiffPreview: React.FC<InlineDiffPreviewProps> = memo(({
285266 < span className = "diff-line__content" >
286267 < SyntaxHighlighter
287268 language = { detectedLanguage }
288- style = { customStyle }
269+ style = { prismStyle }
289270 customStyle = { {
290271 margin : 0 ,
291272 padding : 0 ,
@@ -294,8 +275,9 @@ export const InlineDiffPreview: React.FC<InlineDiffPreviewProps> = memo(({
294275 } }
295276 codeTagProps = { {
296277 style : {
297- fontFamily : "'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace" ,
278+ fontFamily : CODE_PREVIEW_FONT_FAMILY ,
298279 fontSize : '12px' ,
280+ fontWeight : 400 ,
299281 }
300282 } }
301283 PreTag = "span"
@@ -305,7 +287,7 @@ export const InlineDiffPreview: React.FC<InlineDiffPreviewProps> = memo(({
305287 </ span >
306288 </ div >
307289 ) ;
308- } , [ detectedLanguage , showLineNumbers , lineNumberMode , showPrefix , highlightedLine , handleLineClick ] ) ;
290+ } , [ detectedLanguage , prismStyle , showLineNumbers , lineNumberMode , showPrefix , highlightedLine , handleLineClick ] ) ;
309291
310292 if ( ! originalContent && ! modifiedContent ) {
311293 return (
0 commit comments