Skip to content

Commit e5f352e

Browse files
authored
fix: Wrong className when using custom theme (#234)
* feature: allow custom themes * docs: custom theme * bugfix: incorrect cm-theme class name on custom themes * bugfix: use generic defaultClassNames
1 parent 8385eaf commit e5f352e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ const ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProp
123123
// eslint-disable-next-line react-hooks/exhaustive-deps
124124
}, []);
125125

126-
return <div ref={editor} className={`cm-theme-${theme}${className ? ` ${className}` : ''}`} {...other}></div>;
126+
const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';
127+
return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;
127128
});
128129

129130
ReactCodeMirror.displayName = 'CodeMirror';

0 commit comments

Comments
 (0)