@@ -5,6 +5,7 @@ import Highlight, { defaultProps } from 'prism-react-renderer/';
5
5
import ghTheme from 'prism-react-renderer/themes/github' ;
6
6
import vsTheme from 'prism-react-renderer/themes/vsDark' ;
7
7
import tranformImports from './transform-imports' ;
8
+ import clsx from 'clsx' ;
8
9
9
10
const useStyles = makeStyles ( {
10
11
pre : {
@@ -43,7 +44,7 @@ const useStylesCode = makeStyles((theme) => ({
43
44
}
44
45
} ) ) ;
45
46
46
- const CodeEditor = ( { value, children, className, inExample } ) => {
47
+ const CodeEditor = ( { value, children, className, inExample, editorClassname , keepLastLine } ) => {
47
48
const classes = useStylesCode ( { inExample } ) ;
48
49
49
50
const lang = className ? className . toLowerCase ( ) . replace ( 'language-' , '' ) : undefined ;
@@ -60,10 +61,10 @@ const CodeEditor = ({ value, children, className, inExample }) => {
60
61
content = tranformImports ( content ) ;
61
62
}
62
63
63
- content = content . substring ( 0 , content . length - 1 ) ;
64
+ content = keepLastLine ? content : content . substring ( 0 , content . length - 1 ) ;
64
65
65
66
return (
66
- < div className = { classes . wrapper } >
67
+ < div className = { clsx ( classes . wrapper , editorClassname ) } >
67
68
< Highlight { ...defaultProps } theme = { lang === 'bash' ? ghTheme : vsTheme } code = { content } language = { lang || 'jsx' } >
68
69
{ ( { className, style, tokens, getLineProps, getTokenProps } ) => (
69
70
< Pre className = { className } style = { style } >
@@ -87,7 +88,9 @@ CodeEditor.propTypes = {
87
88
value : PropTypes . string ,
88
89
children : PropTypes . string ,
89
90
className : PropTypes . string ,
90
- inExample : PropTypes . bool
91
+ inExample : PropTypes . bool ,
92
+ editorClassname : PropTypes . string ,
93
+ keepLastLine : PropTypes . bool
91
94
} ;
92
95
93
96
export default CodeEditor ;
0 commit comments