33import { getCodemirrorLanguage } from "@/lib/codemirrorLanguage" ;
44import { lineOffsetExtension } from "@/lib/extensions/lineOffsetExtension" ;
55import { SearchResultRange } from "@/lib/types" ;
6- import { defaultHighlightStyle , syntaxHighlighting } from "@codemirror/language" ;
76import { EditorState , StateField , Transaction } from "@codemirror/state" ;
8- import { defaultLightThemeOption , oneDarkHighlightStyle , oneDarkTheme } from "@uiw/react-codemirror" ;
97import { Decoration , DecorationSet , EditorView , lineNumbers } from "@codemirror/view" ;
108import { useMemo , useRef } from "react" ;
119import { LightweightCodeMirror , CodeMirrorRef } from "./lightweightCodeMirror" ;
12- import { useThemeNormalized } from "@/hooks/useThemeNormalized " ;
10+ import { useCodeMirrorTheme } from "@/hooks/useCodeMirrorTheme " ;
1311
1412const markDecoration = Decoration . mark ( {
1513 class : "cm-searchMatch-selected"
@@ -29,19 +27,13 @@ export const CodePreview = ({
2927 lineOffset,
3028} : CodePreviewProps ) => {
3129 const editorRef = useRef < CodeMirrorRef > ( null ) ;
32- const { theme } = useThemeNormalized ( ) ;
30+ const theme = useCodeMirrorTheme ( ) ;
3331
3432 const extensions = useMemo ( ( ) => {
3533 const codemirrorExtension = getCodemirrorLanguage ( language ) ;
3634 return [
3735 EditorView . editable . of ( false ) ,
38- ...( theme === 'dark' ? [
39- syntaxHighlighting ( oneDarkHighlightStyle ) ,
40- oneDarkTheme ,
41- ] : [
42- syntaxHighlighting ( defaultHighlightStyle ) ,
43- defaultLightThemeOption ,
44- ] ) ,
36+ theme ,
4537 lineNumbers ( ) ,
4638 lineOffsetExtension ( lineOffset ) ,
4739 codemirrorExtension ? codemirrorExtension : [ ] ,
0 commit comments