1
- import { FC , PropsWithChildren , useState } from 'react' ;
1
+ import { FC , PropsWithChildren , useContext , useState } from 'react' ;
2
2
import { Link } from 'react-router-dom' ;
3
3
import CodeMirror , { ReactCodeMirrorProps } from '@uiw/react-codemirror' ;
4
4
import * as themes from '@uiw/codemirror-themes-all' ;
5
5
import { langs } from '@uiw/codemirror-extensions-langs' ;
6
6
import styled from 'styled-components' ;
7
- import { Preview } from '../../theme/Preview' ;
7
+ import { Preview , MdContext } from '../../theme/Preview' ;
8
8
import { useTheme } from '../../../utils/useTheme' ;
9
9
import { PageWarpper } from '..' ;
10
10
11
11
const ToolsWapper = styled . div `
12
12
padding: 0 0 23px 0;
13
13
` ;
14
14
15
- export const ThemesAllExample : FC < PropsWithChildren < { source ?: string } > > = ( { source } ) => {
15
+ export const ThemesAllExample : FC < PropsWithChildren > = ( ) => {
16
16
const themesData : Record < string , Omit < ReactCodeMirrorProps [ 'theme' ] , 'dark' | 'light' > > = { } ;
17
17
Object . keys ( themes )
18
18
. filter ( ( item ) => typeof themes [ item as keyof typeof themes ] !== 'function' )
@@ -26,10 +26,11 @@ export const ThemesAllExample: FC<PropsWithChildren<{ source?: string }>> = ({ s
26
26
const changeHandle = ( ev : React . ChangeEvent < HTMLSelectElement > ) => {
27
27
setSelectTheme ( ev . target . value as keyof typeof themesData ) ;
28
28
} ;
29
+ const mdData = useContext ( MdContext ) ;
29
30
return (
30
31
< PageWarpper >
31
32
< CodeMirror
32
- value = { source }
33
+ value = { mdData . mdstr }
33
34
theme = { themeCurrent as ReactCodeMirrorProps [ 'theme' ] }
34
35
height = "300px !important"
35
36
style = { { margin : '0 0 23px 0' } }
0 commit comments