How can i set textarea(.w-md-editor-text-input)'s parent <div> height style?
import t\MDEditor from '@uiw/react-md-editor';
interface Props {
content: string;
changeHandler: (content: string) => void;
}
export default function ArticleContentEditor({ content, changeHandler }: Props) {
const changeContentHandler = (value: string | undefined) => {
if (value) {
changeHandler(value);
}
};
return (
<MDEditor
value={content}
height="500px"
onChange={(changedContent) => changeContentHandler(changedContent)}
highlightEnable={false}
/>
);
}
This is my code, when i set height="500px" on MDEditor Component But not working on textarea, textarea is so small
Need to set more properties of MDEditor?
@imkdw I can't reproduce your issue. Can you provide an example to help me investigate?
@jaywcjlove
Thank you for your response
But I can't find what's wrong.. so I set css height: 100% on class of w-md-editor-text
It doesn't feel right, but it's resolved, so I think I should use it like this
.w-md-editor-text {
height: 100%;
}
I have the same issue exactly.
It looks related to https://github.com/uiwjs/react-md-editor/commit/a7d9a2c266200579e083f70b63effafd08c328d3
Hi found a temp fix referencing comments form @imkdw and @jongyoul, we can use:
.w-md-editor-text { min-height: 100% !important; }
you can try height: 100% as well but for me it breaks cursor placement
Not working for me
<MDEditor
height='100%'
value={values.code}
onChange={(value) => setFieldValue('code', value)}
onBlur={handleBlur}
preview='edit'
className={classNames(
'ui-min-h-40 ui-w-full ui-overflow-auto ui-rounded-xl ui-leading-6 ui-text-justify ui-px-2 ui-text-base placeholder:ui-text-gray-700 ui-items-stretch',
{
'ui-border-gray-300 ': !hasError(errors.code),
'ui-border-red-300 ': hasError(errors.code),
}
)}
hideToolbar
textareaProps={{
name: 'code',
}}
/>
import MDEditor from '@uiw/react-md-editor';
import { useState, useRef, useEffect } from 'react';
import styles from './index.module.scss';
interface MarkDownEditorProps {
height?: string;
placeholder?: string;
}
const MarkDownEditor: React.FC<MarkDownEditorProps> = ({
height,
placeholder,
}) => {
const [value, setValue] = useState<string>('');
const editorRef = useRef<HTMLDivElement | null>(null);
useEffect(() => {
if (editorRef.current) {
const editorElement =
editorRef.current.querySelector('.w-md-editor-text');
if (editorElement) {
editorElement.setAttribute(
'style',
'background-color:rgb(255, 255, 255);'
);
}
}
}, []);
return (
<div className={styles.container} data-color-mode="light" ref={editorRef}>
<MDEditor
height={height}
value={value}
preview="edit"
previewOptions={{
className: styles.customPreview,
}}
visibleDragbar={false}
textareaProps={{
placeholder: placeholder,
}}
/>
</div>
);
};
export default MarkDownEditor;
@buzzracharyeah This solved the problem without css. Please refer to it