@@ -13,10 +13,25 @@ export interface TextareaCodeEditorProps extends React.TextareaHTMLAttributes<HT
1313 * Optional padding for code. Default: `10`.
1414 */
1515 padding ?: number ;
16+ /**
17+ * The minimum height of the editor. Default: `16`.
18+ */
19+ minHeight ?: number ;
1620}
1721
1822export default React . forwardRef < HTMLTextAreaElement , TextareaCodeEditorProps > ( ( props , ref ) => {
19- const { prefixCls = 'w-tc-editor' , value : _ , padding = 10 , language, className, style, onChange, ...other } = props ;
23+ const {
24+ prefixCls = 'w-tc-editor' ,
25+ value : _ ,
26+ padding = 10 ,
27+ minHeight = 16 ,
28+ placeholder,
29+ language,
30+ className,
31+ style,
32+ onChange,
33+ ...other
34+ } = props ;
2035
2136 const [ value , setValue ] = useState ( props . value || '' ) ;
2237 useEffect ( ( ) => setValue ( props . value || '' ) , [ props . value ] ) ;
@@ -33,14 +48,14 @@ export default React.forwardRef<HTMLTextAreaElement, TextareaCodeEditorProps>((p
3348 processHtml (
3449 `<pre aria-hidden=true><code ${ language ? `class="language-${ language } "` : '' } >${ htmlEncode (
3550 String ( value || '' ) ,
36- ) } </code></pre>`,
51+ ) } </code><br />< /pre>`,
3752 ) ,
3853 [ value , language ] ,
3954 ) ;
4055 const preView = useMemo (
4156 ( ) => (
4257 < div
43- style = { { ...contentStyle } }
58+ style = { { ...styles . editor , ... contentStyle , minHeight } }
4459 className = { `${ prefixCls } -preview ${ language ? `language-${ language } ` : '' } ` }
4560 dangerouslySetInnerHTML = { {
4661 __html : htmlStr ,
@@ -59,10 +74,13 @@ export default React.forwardRef<HTMLTextAreaElement, TextareaCodeEditorProps>((p
5974 spellCheck = "false"
6075 autoCapitalize = "off"
6176 { ...other }
77+ placeholder = { placeholder }
6278 style = { {
6379 ...styles . editor ,
6480 ...styles . textarea ,
6581 ...contentStyle ,
82+ minHeight,
83+ ...( placeholder && ! value ? { WebkitTextFillColor : 'inherit' } : { } ) ,
6684 } }
6785 ref = { ref }
6886 onChange = { ( evn ) => {
0 commit comments