()
| 12 | import tailwind from "@/tailwind"; |
| 13 | |
| 14 | export const useCodeMirrorTheme = () => { |
| 15 | const { theme } = useThemeNormalized(); |
| 16 | const highlightStyle = useCodeMirrorHighlighter(); |
| 17 | |
| 18 | const cmTheme = useMemo(() => { |
| 19 | const { |
| 20 | background, |
| 21 | foreground, |
| 22 | caret, |
| 23 | selection, |
| 24 | selectionMatch, |
| 25 | gutterBackground, |
| 26 | gutterForeground, |
| 27 | gutterBorder, |
| 28 | gutterActiveForeground, |
| 29 | lineHighlight, |
| 30 | } = tailwind.theme.colors.editor; |
| 31 | |
| 32 | return [ |
| 33 | createThemeExtension({ |
| 34 | theme: theme === 'dark' ? 'dark' : 'light', |
| 35 | settings: { |
| 36 | background, |
| 37 | foreground, |
| 38 | caret, |
| 39 | selection, |
| 40 | selectionMatch, |
| 41 | gutterBackground, |
| 42 | gutterForeground, |
| 43 | gutterBorder, |
| 44 | gutterActiveForeground, |
| 45 | lineHighlight, |
| 46 | fontFamily: tailwind.theme.fontFamily.editor, |
| 47 | fontSize: tailwind.theme.fontSize.editor, |
| 48 | } |
| 49 | }), |
| 50 | syntaxHighlighting(highlightStyle) |
| 51 | ] |
| 52 | }, [highlightStyle, theme]); |
| 53 | |
| 54 | return cmTheme; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | // @see: https://github.com/uiwjs/react-codemirror/blob/e365f7d1f8a0ec2cd88455b7a248f6338c859cc7/themes/theme/src/index.tsx |
no test coverage detected