@@ -8,10 +8,11 @@ import styles from './styles.css'
88
99export type Props = {
1010 text : string ,
11- prompt : React . Component ,
11+ prompt : string ,
1212 commands : any ,
1313 welcomeMessage ?: string ,
1414 autoFocus : boolean ,
15+ noCommandFound : ( str : string ) => Promise < string > ,
1516}
1617
1718type State = {
@@ -28,6 +29,7 @@ export default class ReactConsole extends React.Component<Props, State> {
2829 static defaultProps = {
2930 prompt : '$' ,
3031 autoFocus : false ,
32+ noCommandFound : ( cmd : string ) => Promise . resolve ( `Command ${ cmd } does not exist` ) ,
3133 } ;
3234
3335 state = {
@@ -71,7 +73,7 @@ export default class ReactConsole extends React.Component<Props, State> {
7173 const [ cmd , ...args ] = inputString . split ( " " ) ;
7274
7375 if ( cmd === 'clear' ) {
74- this . clear ( )
76+ this . clear ( ) ;
7577 return
7678 }
7779
@@ -91,8 +93,9 @@ export default class ReactConsole extends React.Component<Props, State> {
9193 }
9294
9395 } else {
96+ const cmdNotFound = await this . props . noCommandFound ( cmd ) ;
9497 this . setState ( {
95- output : [ ...this . state . output , log , `Command ' ${ cmd } ' does not exist` ]
98+ output : [ ...this . state . output , log , cmdNotFound ]
9699 } )
97100 }
98101 this . setState ( { commandInProgress : false , input : '' } ) ;
@@ -109,7 +112,11 @@ export default class ReactConsole extends React.Component<Props, State> {
109112 < div className = { styles . wrapper } onClick = { this . focusConsole } ref = { ref => this . wrapperRef = ref } >
110113 < div >
111114 { this . state . output . map ( ( line , key ) =>
112- < pre key = { key } className = { styles . line } > { line } </ pre >
115+ < pre
116+ key = { key }
117+ className = { styles . line }
118+ dangerouslySetInnerHTML = { { __html : line } }
119+ />
113120 ) }
114121 </ div >
115122 < form
0 commit comments