@@ -42,6 +42,7 @@ export interface ICodePreviewState {
4242 fullScreen : boolean ;
4343 width : number | string ;
4444 copied : boolean ;
45+ showEdit : boolean ;
4546}
4647
4748export default class CodePreview extends React . PureComponent < ICodePreviewProps , ICodePreviewState > {
@@ -51,6 +52,7 @@ export default class CodePreview extends React.PureComponent<ICodePreviewProps,
5152 errorMessage : '' ,
5253 fullScreen : false ,
5354 copied : false ,
55+ showEdit : false ,
5456 width : 1
5557 }
5658 public static defaultProps : ICodePreviewProps = {
@@ -125,6 +127,7 @@ export default class CodePreview extends React.PureComponent<ICodePreviewProps,
125127 const { width } = this . state ;
126128 this . setState ( {
127129 width : width === 1 ? '50%' : 1 ,
130+ showEdit : true ,
128131 } ) ;
129132 }
130133 public render ( ) {
@@ -164,16 +167,18 @@ export default class CodePreview extends React.PureComponent<ICodePreviewProps,
164167 ) }
165168 { ! noCode && (
166169 < div style = { { overflow : 'hidden' , width : this . state . width , } } >
167- < CodeMirror
168- value = { code }
169- onChange = { ( editor ) => {
170- this . executeCode ( editor . getValue ( ) ) ;
171- } }
172- options = { {
173- theme : 'monokai' ,
174- mode : 'jsx' ,
175- } }
176- />
170+ { this . state . showEdit && (
171+ < CodeMirror
172+ value = { code }
173+ onChange = { ( editor ) => {
174+ this . executeCode ( editor . getValue ( ) ) ;
175+ } }
176+ options = { {
177+ theme : 'monokai' ,
178+ mode : 'jsx' ,
179+ } }
180+ />
181+ ) }
177182 </ div >
178183 ) }
179184 { ! isOneItem && ! ( noCode && noPreview ) && (
@@ -187,7 +192,12 @@ export default class CodePreview extends React.PureComponent<ICodePreviewProps,
187192 >
188193 { icon . copy }
189194 </ div >
190- < div className = { `${ prefixCls } -bar-iconbtns` } onClick = { this . onFullScreen . bind ( this ) } >
195+ < div
196+ className = { classnames ( `${ prefixCls } -bar-iconbtns` , {
197+ [ `${ prefixCls } -bar-copied` ] : this . state . fullScreen ,
198+ } ) }
199+ onClick = { this . onFullScreen . bind ( this ) }
200+ >
191201 { icon . full }
192202 </ div >
193203 </ div >
0 commit comments