@@ -5,6 +5,7 @@ import Highlight, { defaultProps } from 'prism-react-renderer/';
55import ghTheme from 'prism-react-renderer/themes/github' ;
66import vsTheme from 'prism-react-renderer/themes/vsDark' ;
77import tranformImports from './transform-imports' ;
8+ import clsx from 'clsx' ;
89
910const useStyles = makeStyles ( {
1011 pre : {
@@ -43,7 +44,7 @@ const useStylesCode = makeStyles((theme) => ({
4344 }
4445} ) ) ;
4546
46- const CodeEditor = ( { value, children, className, inExample } ) => {
47+ const CodeEditor = ( { value, children, className, inExample, editorClassname , keepLastLine } ) => {
4748 const classes = useStylesCode ( { inExample } ) ;
4849
4950 const lang = className ? className . toLowerCase ( ) . replace ( 'language-' , '' ) : undefined ;
@@ -60,10 +61,10 @@ const CodeEditor = ({ value, children, className, inExample }) => {
6061 content = tranformImports ( content ) ;
6162 }
6263
63- content = content . substring ( 0 , content . length - 1 ) ;
64+ content = keepLastLine ? content : content . substring ( 0 , content . length - 1 ) ;
6465
6566 return (
66- < div className = { classes . wrapper } >
67+ < div className = { clsx ( classes . wrapper , editorClassname ) } >
6768 < Highlight { ...defaultProps } theme = { lang === 'bash' ? ghTheme : vsTheme } code = { content } language = { lang || 'jsx' } >
6869 { ( { className, style, tokens, getLineProps, getTokenProps } ) => (
6970 < Pre className = { className } style = { style } >
@@ -87,7 +88,9 @@ CodeEditor.propTypes = {
8788 value : PropTypes . string ,
8889 children : PropTypes . string ,
8990 className : PropTypes . string ,
90- inExample : PropTypes . bool
91+ inExample : PropTypes . bool ,
92+ editorClassname : PropTypes . string ,
93+ keepLastLine : PropTypes . bool
9194} ;
9295
9396export default CodeEditor ;
0 commit comments