@@ -4,7 +4,7 @@ import { IMarkdownEditor, ToolBarProps } from '../';
44
55const Preview : React . FC < { command : ICommand ; editorProps : IMarkdownEditor & ToolBarProps } > = ( props ) => {
66 const { editorProps } = props ;
7- const { containerEditor, preview } = editorProps ;
7+ const { containerEditor, preview, previewWidth = '50%' } = editorProps ;
88 const [ visible , setVisible ] = useState ( props . editorProps . visible ) ;
99 useEffect ( ( ) => setVisible ( props . editorProps . visible ) , [ props . editorProps . visible ] ) ;
1010 useEffect ( ( ) => {
@@ -14,12 +14,14 @@ const Preview: React.FC<{ command: ICommand; editorProps: IMarkdownEditor & Tool
1414 $preview . style . borderBottomRightRadius = '3px' ;
1515 }
1616 if ( $preview && visible ) {
17- $preview . style . width = '50%' ;
17+ $preview . style . width = previewWidth ;
1818 $preview . style . overflow = 'auto' ;
19- $preview . style . borderLeft = '1px solid var(--color-border-muted)' ;
19+ if ( previewWidth !== '100%' ) {
20+ $preview . style . borderLeft = '1px solid var(--color-border-muted)' ;
21+ }
2022 $preview . style . padding = '20px' ;
2123 if ( containerEditor . current ) {
22- containerEditor . current . style . width = '50%' ;
24+ containerEditor . current . style . width = `calc(100% - ${ previewWidth } )` ;
2325 }
2426 } else if ( $preview ) {
2527 $preview . style . width = '0%' ;
@@ -31,7 +33,7 @@ const Preview: React.FC<{ command: ICommand; editorProps: IMarkdownEditor & Tool
3133 }
3234 }
3335 }
34- } , [ visible , containerEditor , preview ] ) ;
36+ } , [ visible , containerEditor , preview , previewWidth ] ) ;
3537
3638 return (
3739 < button onClick = { ( ) => setVisible ( ! visible ) } type = "button" className = { visible ? 'active' : '' } >
0 commit comments